package com.cdp.web.controller.system;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.*;
import com.cdp.common.utils.SecurityUtils;
import com.cdp.common.utils.StringUtils;
import com.cdp.common.utils.uuid.IdUtils;
import com.cdp.system.dto.AuditRequestDTO;
import com.cdp.system.dto.CheckMechanicalPerformanceDTO;
import com.cdp.system.dto.SaveDataDTO;
import com.cdp.system.dto.SysExcelAuditDTO;
import com.cdp.system.mapper.SysCementMapper;
import com.cdp.system.mapper.SysFlyashMapper;
import com.cdp.system.mapper.SysRegionMapper;
import com.cdp.system.mapper.sysFileAuditMapper;
import com.cdp.system.service.*;
import com.cdp.system.vo.SysExcelAuditVO;
import com.cdp.system.vo.UpdateExcelAuditDTO;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.sql.Timestamp;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;

import static org.apache.logging.log4j.util.Strings.isBlank;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.Region;
import com.cdp.common.core.domain.entity.SysCement;
import com.cdp.system.service.ISysUserFileService;
import com.cdp.system.service.impl.RegionServiceImpl;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.*;
import java.util.stream.Collectors;

@RestController
@RequestMapping
@Slf4j
public class SysExcelAuditController {


    @Autowired
    private IExcelFileHistoryService excelFileHistoryService;
    // 读取文件保存路径
    @Value("${file.upload-dir}")
    private String uploadDir;
    @Autowired
    private sysFileAuditMapper sysFileAuditMapper;

    @Autowired
    private RegionServiceImpl regionService;
    @Autowired
    private ISysFlyashService sysFlyashService;
    @Autowired
    private SysFlyashMapper sysFlyashMapper;
    @Autowired
    private SysCementMapper sysCementMapper;
    @Autowired
    private ISysCementService sysCementService;

    @Autowired
    private ISysSandService sysSandService;

    @Autowired
    private ISysStoneService sysStoneService;

    @Autowired
    private SysRegionMapper sysRegionMapper;


    @Autowired
    private SysOtherAdmixturesService sysOtherAdmixturesService;

    @Autowired
    private ISysMineralPowderService sysMineralPowderService;

    @Autowired
    private ISysWaterReducerService sysWaterReducerService;

    @Autowired
    private ISysEfficiencyAgentService sysEfficiencyAgentService;


    @Autowired
    private ISysSwellingagentService sysSwellingagentService;
    @Autowired
    private ISysMechanicalPerformanceService sysMechanicalPerformanceService;


    @Autowired
    private ISysSlumpService sysSlumpService;


    @Autowired
    private SysExcelAuditService sysExcelAuditService;


    @Value("${filePython.upload-directory}")
    private String uploadDirectory;



    /**
     * 力学性能上载
     *
     * @param file
     * @param name
     * @return
     */

    @PostMapping("/upload/mechanical/performance/excel")
    @Transactional
    public AjaxResult upload(@RequestParam("file") MultipartFile file,
                             @RequestParam("name") String name,
                             @RequestParam(value = "type", required = false, defaultValue = "0") Integer type) {
        List<List<String>> data = new ArrayList<>();

        // 文件类型校验
        String filename = file.getOriginalFilename();
        if (filename == null || !filename.endsWith(".xlsx")) {
            return AjaxResult.error("文件格式错误，请上传 .xlsx 格式的 Excel 文件");
        }

        try (InputStream is = file.getInputStream();
             Workbook workbook = new XSSFWorkbook(is)) {
            Sheet sheet = workbook.getSheetAt(0); // 读取第一个 sheet
            for (Row row : sheet) {
                if (row == null) {
                    continue;
                }
                List<String> rowData = new ArrayList<>();
                for (Cell cell : row) {
                    rowData.add(getCellValue(cell));
                }
                data.add(rowData);
            }

//            // 移除表头
            if (!data.isEmpty()) {
                data.remove(0);
            }


            // 1. 保存原始 Excel 到本地
            String savedPath = saveExcelToLocal(file);  //


            // 2.保存json到服务器 返回的是文件路径
            String filePath = saveDataToFile(data,name );

//            SysExcelAudit sysExcelAudit = new SysExcelAudit();
//            sysExcelAudit.setFilePath(filePath);
//            sysExcelAudit.setExcelPath(savedPath);
//            sysExcelAudit.setVersion(0);
//            sysExcelAudit.setDeleteTime(0);
//            sysExcelAudit.setTableName(name);
//            sysExcelAudit.setId(IdUtils.generateRandomNumber());
//            sysExcelAudit.setUserId(SecurityUtils.getUserId());
//            sysExcelAudit.setType(type);
//            sysExcelAuditService.save(sysExcelAudit);
            ExcelFileHistory sysExcelAudit = new ExcelFileHistory();
            sysExcelAudit.setFilePath(filePath);
            sysExcelAudit.setFilePath(savedPath);
            sysExcelAudit.setVersion(0);
            sysExcelAudit.setDeleteTime(0);
            sysExcelAudit.setFileName(name);
            sysExcelAudit.setId(IdUtils.generateRandomNumber());
            sysExcelAudit.setUserId(SecurityUtils.getUserId());
            sysExcelAudit.setType(type);
            excelFileHistoryService.save(sysExcelAudit);

            System.out.println("dataHHH" + data);
            // 校验数据（方法内部可抛出异常）
            AjaxResult ajaxResult = checkMechanicalPerformanceV3(data, savedPath, name);

            return ajaxResult;

        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("读取失败：" + e.getMessage());
        } catch (Exception ex) {
            ex.printStackTrace();
            return AjaxResult.error("校验失败：" + ex.getMessage());
        }
    }

    private String saveDataToFile(List<List<String>> data, String baseFileName) {
        // 生成唯一文件名：毫秒时间戳 + 3位随机数字
        String timestamp = String.valueOf(System.currentTimeMillis());
        String randomSuffix = String.format("%03d", new Random().nextInt(1000));
        String finalFileName = baseFileName + "_" + timestamp + randomSuffix + ".json";

        String filePath = uploadDir + finalFileName;
        // 使用 ObjectMapper 将数据转换为 JSON 格式并保存到文件中
        ObjectMapper objectMapper = new ObjectMapper();
        try (FileWriter fileWriter = new FileWriter(filePath)) {
            String jsonData = objectMapper.writeValueAsString(data);
            fileWriter.write(jsonData);
            fileWriter.flush();
        } catch (IOException e) {
            throw new RuntimeException("文件保存失败", e);
        }

        return filePath;
    }

    /**
     * 插入力学性能
     *
     * @param
     * @return
     */
    @PostMapping("/check/mechanical/performance")
    @Transactional
    public AjaxResult checkMechanicalPerformance(@RequestBody CheckMechanicalPerformanceDTO checkMechanicalPerformanceDTO) {

        Integer id = checkMechanicalPerformanceDTO.getId();
        Integer status = checkMechanicalPerformanceDTO.getStatus();
        String reason = checkMechanicalPerformanceDTO.getReason();

        SysExcelAudit sysExcelAudit = sysExcelAuditService.getOne(
                new LambdaQueryWrapper<SysExcelAudit>().eq(SysExcelAudit::getId, id)
        );

        if (sysExcelAudit == null) {
            return AjaxResult.error("审核记录不存在");
        }
        Integer type = sysExcelAudit.getType();
        if (type != 0) {
            return AjaxResult.error("不是力学性能数据");
        }

        String excelPath = sysExcelAudit.getFilePath();
        AjaxResult ajaxResult;

        if (status == 1) {
            ajaxResult = saveSysMechanicalPerformance(excelPath);

            if (ajaxResult.isError()) {
                return ajaxResult; // 返回校验失败信息
            }

            // 审核通过，更新状态
            LambdaUpdateWrapper<SysExcelAudit> updateWrapper = new LambdaUpdateWrapper<>();
            updateWrapper.eq(SysExcelAudit::getId, id)
                    .set(SysExcelAudit::getStatus, 1)
                    .set(SysExcelAudit::getUpdateTime, LocalDateTime.now())
                    .set(SysExcelAudit::getReason, reason);

            boolean success = sysExcelAuditService.update(updateWrapper);

            if (success) {
                return AjaxResult.success("审核通过，" + ajaxResult.get("msg"));
            } else {
                return AjaxResult.error("审核通过失败，数据库更新失败");
            }
        } else if (status == 2) {
            // 审核不通过，直接更新状态
            LambdaUpdateWrapper<SysExcelAudit> updateWrapper = new LambdaUpdateWrapper<>();
            updateWrapper.eq(SysExcelAudit::getId, id)
                    .set(SysExcelAudit::getStatus, 2)
                    .set(SysExcelAudit::getUpdateTime, LocalDateTime.now())
                    .set(SysExcelAudit::getReason, reason);

            boolean success = sysExcelAuditService.update(updateWrapper);
            return success ? AjaxResult.success("审核未通过") : AjaxResult.error("状态更新失败");
        }

        return AjaxResult.error("非法状态码");
    }


//    @PostMapping("/check/mechanical/performance")
//    @Transactional
//    public AjaxResult checkMechanicalPerformance(@RequestBody CheckMechanicalPerformanceDTO checkMechanicalPerformanceDTO) {
//
//
//        LambdaQueryWrapper<SysExcelAudit> wrapper = new LambdaQueryWrapper<>();
//        wrapper.eq(SysExcelAudit::getId,checkMechanicalPerformanceDTO.getId());
//        SysExcelAudit sysExcelAudit = sysExcelAuditService.getOne(wrapper);
//        String excelPath = sysExcelAudit.getFilePath();
//
////            // 移除表头
////            if (!data.isEmpty()) {
////                data.remove(0);
////            }
//
//
//            // 校验数据（方法内部可抛出异常）
//        AjaxResult ajaxResult = saveSysMechanicalPerformance(excelPath);
//
//
//        return ajaxResult;
//
//
//    }
//


    /*力学性能数据插入校验*/
    @Transactional
    public AjaxResult saveSysMechanicalPerformance(String filePath) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }


        int successfulInserts = 0;


        // 获取水泥数据并存储在一个集合中
        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        List<SysCement> list = sysCementService.list(wrapper);
        Map<String, SysCement> sysCementMap = new HashMap<>();

        for (SysCement sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getRegionName() + "-" + sysCement.getStrengthGrade() +
                    "-" + sysCement.getCaoContent() + "-" + sysCement.getSio2Content() + "-" + sysCement.getAl2o3Content() + "-" + sysCement.getCompressiveStrength28d();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石头记录并存储在一个集合中
        LambdaQueryWrapper<SysStone> wrapperStone = new LambdaQueryWrapper<>();
        List<SysStone> listStone = sysStoneService.list(wrapperStone);
        Map<String, SysStone> sysStonMap = new HashMap<>();
        System.out.println("sysCementMap" + sysStonMap);
        for (SysStone sysCement : listStone) {
            String keyStone = sysCement.getModel() + "-" + sysCement.getStoneSpecification() +
                    "-" + sysCement.getStackingDensity() + "-" + sysCement.getCompactDensity() +
                    "-" + sysCement.getBulkDensity() + "-" + sysCement.getRegionName();

            sysStonMap.put(keyStone, sysCement);
        }


        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysFlyash> wrapperFlyash = new LambdaQueryWrapper<>();
        List<SysFlyash> listFlyash = sysFlyashService.list(wrapperFlyash);
        Map<String, SysFlyash> flyashMap = new HashMap<>();

        for (SysFlyash sysCement : listFlyash) {
            String keyFlyash = sysCement.getGrade() + "-" + sysCement.getFactoryGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            flyashMap.put(keyFlyash, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的砂记录并存储在一个集合中
        LambdaQueryWrapper<SysSand> wrapperSand = new LambdaQueryWrapper<>();
        List<SysSand> listSand = sysSandService.list(wrapperSand);
        // 使用一个唯一的组合键作为 Map 的 key
        Map<String, SysSand> sysSandMap = new HashMap<>();
        for (SysSand sysCement : listSand) {
            String key = sysCement.getType() + "-" + sysCement.getFineness() + "-" + sysCement.getBulkDensity() + "-"
                    + sysCement.getCompactDensity() + "-" + sysCement.getApparentDensity() + "-" + sysCement.getParticleSizeDistribution()
                    + "-" + sysCement.getRegionName();
            sysSandMap.put(key, sysCement);  // 使用唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石粉记录并存储在一个集合中
        LambdaQueryWrapper<SysOtherAdmixtures> wrapperOtherAdmixtures = new LambdaQueryWrapper<>();
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list(wrapperOtherAdmixtures);
        Map<String, SysOtherAdmixtures> sysOtherAdmixturesMap = new HashMap<>();
        System.out.println("sysCementMap" + sysCementMap);
        for (SysOtherAdmixtures sysCement : listOtherAdmixtures) {
            String key = sysCement.getModel() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            sysOtherAdmixturesMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*矿粉*/
        LambdaQueryWrapper<SysMineralPowder> wrapperMineralPowder = new LambdaQueryWrapper<>();
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list(wrapperMineralPowder);
        Map<String, SysMineralPowder> MineralPowderMap = new HashMap<>();

        for (SysMineralPowder sysCement : listMineralPowder) {
            String key = sysCement.getModel() + "-" + sysCement.getSlagGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            MineralPowderMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        //减水剂
        LambdaQueryWrapper<SysWaterReducer> wrapperWaterReducer = new LambdaQueryWrapper<>();
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list(wrapperWaterReducer);
        Map<String, SysWaterReducer> sysWaterReducerMap = new HashMap<>();
        System.out.println("list" + list);
        for (SysWaterReducer sysCement : listWaterReducer) {
            String keyWaterReducer = sysCement.getModel() + "-" + sysCement.getSolidContent() + "-" + sysCement.getCementPasteFlow() + "-" + sysCement.getReducingRate() + "-" + sysCement.getSourceName();

            sysWaterReducerMap.put(keyWaterReducer, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        System.out.println("减水剂数据库字段" + sysWaterReducerMap);

        /*增效剂*/
        LambdaQueryWrapper<SysEfficiencyAgent> wrapperEfficiencyAgent = new LambdaQueryWrapper<>();
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgentService.list(wrapperEfficiencyAgent);
        Map<String, SysEfficiencyAgent> efficiencyAgentMap = new HashMap<>();
        System.out.println("list" + listEfficiencyAgent);
        for (SysEfficiencyAgent sysCement : listEfficiencyAgent) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            efficiencyAgentMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*膨胀剂*/
        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysSwellingagent> wrapperSwellingagent = new LambdaQueryWrapper<>();
        List<SysSwellingagent> listSysSwelling = sysSwellingagentService.list(wrapperSwellingagent);
        Map<String, SysSwellingagent> SysSwellingMap = new HashMap<>();
        System.out.println("list" + listSysSwelling);
        for (SysSwellingagent sysCement : listSysSwelling) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            SysSwellingMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 创建一个临时列表，用于存储要插入的数据
        List<SysMechanicalPerformance> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
//            if (record.size() != 15) {
//                System.err.println("无效数据格式: " + record);
//                continue;
//            }


            // 解析数据
            //String regiona = record.get(0);  // 地区
            int regiona = Integer.parseInt(record.get(0));//来源地区

            // String productionDate = record.get(1);  // //生产日期
            String productionDateStr = record.get(1);
            LocalDateTime productionDate = LocalDate.parse(productionDateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
                    .atStartOfDay();


            String strengthGrade = record.get(2);
            ;//强度等级
            BigDecimal compressive3d = new BigDecimal(record.get(3));
            ;//3天抗压强度(MPa)
            BigDecimal compressive7d = new BigDecimal(record.get(4));  //7天抗压强度(MPa)
            BigDecimal compressive28d = new BigDecimal(record.get(5));  //28天抗压强度(MPa)
            BigDecimal water = new BigDecimal(record.get(6));   //水掺量(kg/m³)

            BigDecimal cement = new BigDecimal(record.get(7));
            ;////水泥掺量(kg/m³)

            water = water.setScale(2, RoundingMode.HALF_UP);
            cement = cement.setScale(2, RoundingMode.HALF_UP);







            /*水泥*/
            // 解析数据
            String model = record.get(8);
            BigDecimal cao = new BigDecimal(record.get(9));
            BigDecimal sio2 = new BigDecimal(record.get(10));
            BigDecimal al2o3 = new BigDecimal(record.get(11));
            BigDecimal compressive = new BigDecimal(record.get(12));
            BigDecimal strength = new BigDecimal(record.get(13));
            int region = Integer.parseInt(record.get(14));

            // 确保所有 BigDecimal 保留两位小数
            cao = cao.setScale(2, RoundingMode.HALF_UP);
            sio2 = sio2.setScale(2, RoundingMode.HALF_UP);
            al2o3 = al2o3.setScale(2, RoundingMode.HALF_UP);
            compressive = compressive.setScale(2, RoundingMode.HALF_UP);
            strength = strength.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String key = model + "-" + region + "-" + strength + "-" + cao + "-" + sio2 + "-" + al2o3 + "-" + compressive;

            Integer cementId;

            if (sysCementMap.containsKey(key)) {
                // 记录存在，直接拿id
//                cementId = sysCementMap.get(key).getId();
                cementId = sysCementMap.get(key).getCementId();  // 使用正确的字段名称
                System.out.println("找到已有水泥数据，id = " + cementId);
            } else {
                // 记录不存在，创建新的SysCement
                SysCement newCement = new SysCement();
                newCement.setId(IdUtils.generateRandomNumber());  // 生成id
                newCement.setModel(model);
                newCement.setRegionName(region); // 注意，regionName是字符串！
                newCement.setStrengthGrade(strength);
                newCement.setCaoContent(cao);
                newCement.setSio2Content(sio2);
                newCement.setAl2o3Content(al2o3);
                newCement.setCompressiveStrength28d(compressive);
                newCement.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));

                sysCementService.save(newCement);
                sysCementMap.put(key, newCement); // 插入map缓存
                cementId = newCement.getId();
                System.out.println("新增水泥数据，id = " + cementId);
            }
//            // 替换第8列（索引8）为水泥id
//            record.set(8, String.valueOf(cementId));
//          // 删除索引9到14的元素（一定要从大到小删）
//            for (int i = 14; i >= 9; i--) {
//                record.remove(i);
//            }


            /*-------------------------------------------------------------------------------------*/
            // String stone510 = record.get(15);// 石头5-10掺量
            BigDecimal stone510 = new BigDecimal(record.get(15));// 石头5-10掺量
            stone510 = stone510.setScale(2, RoundingMode.HALF_UP);

            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone510 = record.get(16); // 型号
            String stoneSpecification510 = record.get(17); // 石子规格
            BigDecimal stackingDensity510 = new BigDecimal(record.get(18)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity510 = new BigDecimal(record.get(19)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity510 = new BigDecimal(record.get(20)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName = record.get(21); // 来源地区

            Integer regionName510 = Integer.parseInt(regionName);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone510 = modelstone510 + "-" + stoneSpecification510 + "-" + stackingDensity510 + "-" + compactDensity510 + "-" + bulkDensity510 + "-" + regionName510;
            System.out.println("key: " + key);

            Integer stone510Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone510)) {
                stone510Id = sysStonMap.get(keyModelStone510).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在水泥数据stone510Id" + stone510Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone510);
                sysStone.setStoneSpecification(stoneSpecification510);
                sysStone.setStackingDensity(stackingDensity510);
                sysStone.setCompactDensity(compactDensity510);
                sysStone.setBulkDensity(bulkDensity510);
                sysStone.setRegionName(regionName510);
                sysStone.setId(IdUtils.generateRandomNumber());

                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone510, sysStone);
                stone510Id = sysStone.getStoneId();
                System.out.println("新增石头数据，id = " + stone510Id);
            }


            /*石头石5-25mm----------------------------*/


            //String stone525 = record.get(22);// 石头5-10掺量
            BigDecimal stone525 = new BigDecimal(record.get(22));// 石头5-10掺量
            stone525 = stone525.setScale(2, RoundingMode.HALF_UP);




            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone525 = record.get(23); // 型号
            String stoneSpecification525 = record.get(24); // 石子规格
            BigDecimal stackingDensity525 = new BigDecimal(record.get(25)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity525 = new BigDecimal(record.get(26)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity525 = new BigDecimal(record.get(27)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName525 = record.get(28); // 来源地区
            Integer regionName525s = Integer.parseInt(regionName525);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone525 = modelstone525 + "-" + stoneSpecification525 + "-" + stackingDensity525 + "-" + compactDensity525 + "-" + bulkDensity525 + "-" + regionName525s;
            System.out.println("key: " + key);

            Integer stone525Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone525)) {
                stone525Id = sysStonMap.get(keyModelStone525).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone510Id" + stone525Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone525);
                sysStone.setStoneSpecification(stoneSpecification525);
                sysStone.setStackingDensity(stackingDensity525);
                sysStone.setCompactDensity(compactDensity525);
                sysStone.setBulkDensity(bulkDensity525);
                sysStone.setRegionName(regionName525s);
                sysStone.setId(IdUtils.generateRandomNumber());

                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone525, sysStone);
                stone525Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone525，id = " + stone525Id);
            }

            /*石头石20-40mm----------------------------*/

            // String stone2040 = record.get(29);// 石头20-40掺量

            BigDecimal stone2040 = new BigDecimal(record.get(29));// 石头20-40掺量
            stone2040 = stone2040.setScale(2, RoundingMode.HALF_UP);



            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone2040 = record.get(30); // 型号
            String stoneSpecification2040 = record.get(31); // 石子规格
            BigDecimal stackingDensity2040 = new BigDecimal(record.get(32)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity2040 = new BigDecimal(record.get(33)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity2040 = new BigDecimal(record.get(34)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName2040 = record.get(35); // 来源地区
            Integer regionName2040s = Integer.parseInt(regionName2040);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone2040 = modelstone2040 + "-" + stoneSpecification2040 + "-" + stackingDensity2040 + "-" + compactDensity2040 + "-" + bulkDensity2040 + "-" + regionName2040s;
            System.out.println("key: " + keyModelStone2040);

            Integer stone2040Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone2040)) {
                stone2040Id = sysStonMap.get(keyModelStone2040).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone2040Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone2040);
                sysStone.setStoneSpecification(stoneSpecification2040);
                sysStone.setStackingDensity(stackingDensity2040);
                sysStone.setCompactDensity(compactDensity2040);
                sysStone.setBulkDensity(bulkDensity2040);
                sysStone.setRegionName(regionName2040s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone2040Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone525，id = " + stone2040Id);
            }


            /*石头20-20*/

            //  String stone1020 = record.get(36);// 石头10-50掺量

            BigDecimal stone1020 = new BigDecimal(record.get(36));// 石头5-10掺量
            stone1020 = stone1020.setScale(2, RoundingMode.HALF_UP);


            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone1020 = record.get(37); // 型号
            String stoneSpecification1020 = record.get(38); // 石子规格
            BigDecimal stackingDensity1020 = new BigDecimal(record.get(39)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1020 = new BigDecimal(record.get(40)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1020 = new BigDecimal(record.get(41)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1020 = record.get(42); // 来源地区
            Integer regionName1020s = Integer.parseInt(regionName1020);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1020 = modelstone1020 + "-" + stoneSpecification1020 + "-" + stackingDensity1020 + "-" + compactDensity1020 + "-" + bulkDensity1020 + "-" + regionName1020s;
            System.out.println("key: " + keyModelStone1020);

            Integer stone1020Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1020)) {
                stone1020Id = sysStonMap.get(keyModelStone1020).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone1020Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1020);
                sysStone.setStoneSpecification(stoneSpecification1020);
                sysStone.setStackingDensity(stackingDensity1020);
                sysStone.setCompactDensity(compactDensity1020);
                sysStone.setBulkDensity(bulkDensity1020);
                sysStone.setRegionName(regionName1020s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone1020Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone1020，id = " + stone1020Id);
            }

            /*石头10-30*/

            // String stone1030 = record.get(43);// 石头10-30掺量

            BigDecimal stone1030 = new BigDecimal(record.get(43));// 石头10-30掺量
            stone1030 = stone1030.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone1030 = record.get(44); // 型号
            String stoneSpecification1030 = record.get(45); // 石子规格
            BigDecimal stackingDensity1030 = new BigDecimal(record.get(46)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1030 = new BigDecimal(record.get(47)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1030 = new BigDecimal(record.get(48)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1030 = record.get(49); // 来源地区
            Integer regionName1030s = Integer.parseInt(regionName1030);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1030 = modelstone1030 + "-" + stoneSpecification1030 + "-" + stackingDensity1030 + "-" + compactDensity1030 + "-" + bulkDensity1030 + "-" + regionName1030s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone1030Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1030)) {
                stone1030Id = sysStonMap.get(keyModelStone1030).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone1030Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1030);
                sysStone.setStoneSpecification(stoneSpecification1030);
                sysStone.setStackingDensity(stackingDensity1030);
                sysStone.setCompactDensity(compactDensity1030);
                sysStone.setBulkDensity(bulkDensity1030);
                sysStone.setRegionName(regionName1030s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone1030, sysStone);
                stone1030Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone1020，id = " + stone1030Id);
            }

            /*石头0-10*/

            //String stone010 = record.get(50);// 石头0-10掺量

            BigDecimal stone010 = new BigDecimal(record.get(50));//石头0-10掺
            stone010 = stone010.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone010 = record.get(51); // 型号
            String stoneSpecification010 = record.get(52); // 石子规格
            BigDecimal stackingDensity010 = new BigDecimal(record.get(53)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity010 = new BigDecimal(record.get(54)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity010 = new BigDecimal(record.get(55)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName010 = record.get(56); // 来源地区
            Integer regionName010s = Integer.parseInt(regionName010);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone010 = modelstone010 + "-" + stoneSpecification010 + "-" + stackingDensity010 + "-" + compactDensity010 + "-" + bulkDensity010 + "-" + regionName010s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone010Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone010)) {
                stone010Id = sysStonMap.get(keyModelStone010).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone010Id" + stone010Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone010);
                sysStone.setStoneSpecification(stoneSpecification010);
                sysStone.setStackingDensity(stackingDensity010);
                sysStone.setCompactDensity(compactDensity010);
                sysStone.setBulkDensity(bulkDensity010);
                sysStone.setRegionName(regionName010s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone010, sysStone);
                stone010Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone010，id = " + stone010Id);
            }




            /*石头20-315*/

            //  String stone20315 = record.get(57);// 石头20-315掺量

            BigDecimal stone20315 = new BigDecimal(record.get(57));// 石头5-10掺量
            stone20315 = stone20315.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone20315 = record.get(58); // 型号
            String stoneSpecification20315 = record.get(59); // 石子规格
            BigDecimal stackingDensity20315 = new BigDecimal(record.get(60)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity20315 = new BigDecimal(record.get(61)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity20315 = new BigDecimal(record.get(62)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName20315 = record.get(63); // 来源地区
            Integer regionName20315s = Integer.parseInt(regionName20315);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone20315 = modelstone20315 + "-" + stoneSpecification20315 + "-" + stackingDensity20315 + "-" + compactDensity20315 + "-" + bulkDensity20315 + "-" + regionName20315s;
            System.out.println("key: " + keyModelStone20315);

            Integer stone20315Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone20315)) {
                stone20315Id = sysStonMap.get(keyModelStone20315).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone20315Id" + stone20315Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone20315);
                sysStone.setStoneSpecification(stoneSpecification20315);
                sysStone.setStackingDensity(stackingDensity20315);
                sysStone.setCompactDensity(compactDensity20315);
                sysStone.setBulkDensity(bulkDensity20315);
                sysStone.setRegionName(regionName20315s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone20315, sysStone);
                stone20315Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone010，id = " + stone20315Id);
            }

            /*河沙粗 31-37*/
            // String sand3137 = record.get(64);//砂3137参量

            BigDecimal sand3137 = new BigDecimal(record.get(64));// 石头5-10掺量
            sand3137 = sand3137.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137 = record.get(65);  // 砂3137型号
            BigDecimal sandFineness3137 = new BigDecimal(record.get(66));  // 砂3137细度
            BigDecimal sandBulkDensity3137 = new BigDecimal(record.get(67));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137 = new BigDecimal(record.get(68));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137 = new BigDecimal(record.get(69));  // 砂3137表观密度 (kg/m3)

            String sandParticleSizeDistribution = record.get(70);  //砂3137 粒径分布(mm)
            int regionSand3137 = Integer.parseInt(record.get(71));

            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137 = sandFineness3137.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137 = sandBulkDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137 = sandCompactDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137 = sandApparentDensity3137.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137 = sandModel3137 + "-" + sandFineness3137 + "-" + sandBulkDensity3137 + "-" + sandCompactDensity3137 + "-" + sandApparentDensity3137 + "-"
                    + sandParticleSizeDistribution + "-" + regionSand3137;
            System.out.println("key: " + keySand3137);


            Integer sand3137Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137)) {
                sand3137Id = sysSandMap.get(keySand3137).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand3137Id" + sand3137Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137);
                sysSand.setFineness(sandFineness3137);
                sysSand.setBulkDensity(sandBulkDensity3137);
                sysSand.setCompactDensity(sandCompactDensity3137);
                sysSand.setApparentDensity(sandApparentDensity3137);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution);
                sysSand.setRegionName(regionSand3137);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand3137, sysSand);
                sand3137Id = sysSand.getSandId();

                System.out.println("新增砂头数据sandId3137，id = " + sand3137Id);
            }

            /*河沙粗 23-30*/

            // String sand2330 = record.get(72);//砂3137参量
            BigDecimal sand2330 = new BigDecimal(record.get(72));// 石头5-10掺量
            sand2330 = sand2330.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330 = record.get(73);  // 砂3137型号
            BigDecimal sandFineness2330 = new BigDecimal(record.get(74));  // 砂3137细度
            BigDecimal sandBulkDensity2330 = new BigDecimal(record.get(75));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330 = new BigDecimal(record.get(76));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330 = new BigDecimal(record.get(77));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330 = record.get(78);  //砂3137 粒径分布(mm)
            int regionSand2330 = Integer.parseInt(record.get(79));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330 = sandFineness2330.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330 = sandBulkDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330 = sandCompactDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330 = sandApparentDensity2330.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330 = sandModel2330 + "-" + sandFineness2330 + "-" + sandBulkDensity2330 + "-" + sandCompactDensity2330 + "-" + sandApparentDensity2330 + "-"
                    + sandParticleSizeDistribution2330 + "-" + regionSand2330;
            System.out.println("key: " + keySand2330);


            Integer sand2330Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330)) {
                sand2330Id = sysSandMap.get(keySand2330).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand2330Id" + sand2330Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330);
                sysSand.setFineness(sandFineness2330);
                sysSand.setBulkDensity(sandBulkDensity2330);
                sysSand.setCompactDensity(sandCompactDensity2330);
                sysSand.setApparentDensity(sandApparentDensity2330);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand2330, sysSand);
                sand2330Id = sysSand.getSandId();

                System.out.println("新增砂头数据sand2330Id，id = " + sand2330Id);
            }

            /*河砂细16-22mm*/

            // String sand1622 = record.get(80);//砂316 22参量

            BigDecimal sand1622 = new BigDecimal(record.get(80));// 石头5-10掺量
            sand1622 = sand1622.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622 = record.get(81);  // 砂3137型号
            BigDecimal sandFineness1622 = new BigDecimal(record.get(82));  // 砂3137细度
            BigDecimal sandBulkDensity1622 = new BigDecimal(record.get(83));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622 = new BigDecimal(record.get(84));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622 = new BigDecimal(record.get(85));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622 = record.get(86);  //砂3137 粒径分布(mm)
            int regionSand1622 = Integer.parseInt(record.get(87));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622 = sandFineness1622.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622 = sandBulkDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622 = sandCompactDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622 = sandApparentDensity1622.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622 = sandModel1622 + "-" + sandFineness1622 + "-" + sandBulkDensity1622 + "-" + sandCompactDensity1622 + "-" + sandApparentDensity1622 + "-"
                    + sandParticleSizeDistribution1622 + "-" + regionSand1622;
            System.out.println("key: " + keySand1622);


            Integer sand1622Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622)) {
                sand1622Id = sysSandMap.get(keySand1622).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand1622Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622);
                sysSand.setFineness(sandFineness1622);
                sysSand.setBulkDensity(sandBulkDensity1622);
                sysSand.setCompactDensity(sandCompactDensity1622);
                sysSand.setApparentDensity(sandApparentDensity1622);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand1622, sysSand);
                sand1622Id = sysSand.getSandId();

                System.out.println("新增砂头数据sand1622Id，id = " + sand1622Id);
            }
            /*机制砂中23-30Bmm*/
            //  String sand2330B = record.get(88);//砂3137参量
            BigDecimal sand2330B = new BigDecimal(record.get(88));// 机制砂中23-30B
            sand2330B = sand2330B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330B = record.get(89);  // 砂3137型号
            BigDecimal sandFineness2330B = new BigDecimal(record.get(90));  // 砂3137细度
            BigDecimal sandBulkDensity2330B = new BigDecimal(record.get(91));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330B = new BigDecimal(record.get(92));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330B = new BigDecimal(record.get(93));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330B = record.get(94);  //砂3137 粒径分布(mm)
            int regionSand2330B = Integer.parseInt(record.get(95));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330B = sandFineness2330B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330B = sandBulkDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330B = sandCompactDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330B = sandApparentDensity2330B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330B = sandModel2330B + "-" + sandFineness2330B + "-" + sandBulkDensity2330B + "-" + sandCompactDensity2330B + "-" + sandApparentDensity2330B + "-"
                    + sandParticleSizeDistribution2330B + "-" + regionSand2330B;
            System.out.println("key: " + keySand2330B);


            Integer sand2330BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330B)) {
                sand2330BId = sysSandMap.get(keySand2330B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand2330BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330B);
                sysSand.setFineness(sandFineness2330B);
                sysSand.setBulkDensity(sandBulkDensity2330B);
                sysSand.setCompactDensity(sandCompactDensity2330B);
                sysSand.setApparentDensity(sandApparentDensity2330B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330B);
                sysSand.setRegionName(regionSand2330B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand2330B, sysSand);
                sand2330BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand2330BId);
            }


            /*机制粗中31-37Bmm*/
            // String sand3137B = record.get(96);//砂3137参量

            BigDecimal sand3137B = new BigDecimal(record.get(96));// 石头5-10掺量
            sand3137B = sand3137B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137B = record.get(97);  // 砂3137型号
            BigDecimal sandFineness3137B = new BigDecimal(record.get(98));  // 砂3137细度
            BigDecimal sandBulkDensity3137B = new BigDecimal(record.get(99));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137B = new BigDecimal(record.get(100));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137B = new BigDecimal(record.get(101));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution3137B = record.get(102);  //砂3137 粒径分布(mm)
            int regionSand3137B = Integer.parseInt(record.get(103));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137B = sandFineness3137B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137B = sandBulkDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137B = sandCompactDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137B = sandApparentDensity3137B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137B = sandModel3137B + "-" + sandFineness3137B + "-" + sandBulkDensity3137B + "-" + sandCompactDensity3137B + "-" + sandApparentDensity3137B + "-"
                    + sandParticleSizeDistribution3137B + "-" + regionSand3137B;
            System.out.println("key: " + keySand2330B);


            Integer sand3137BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137B)) {
                sand3137BId = sysSandMap.get(keySand3137B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand3137BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137B);
                sysSand.setFineness(sandFineness3137B);
                sysSand.setBulkDensity(sandBulkDensity3137B);
                sysSand.setCompactDensity(sandCompactDensity3137B);
                sysSand.setApparentDensity(sandApparentDensity3137B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution3137B);
                sysSand.setRegionName(regionSand3137B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand3137B, sysSand);
                sand3137BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand3137BId);
            }

            /*机制砂细16-22Bmm*/
            // String sand1622B = record.get(104);//砂3137参量

            BigDecimal sand1622B = new BigDecimal(record.get(104));// 石头5-10掺量
            sand1622B = sand1622B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622B = record.get(105);  // 砂3137型号
            BigDecimal sandFineness1622B = new BigDecimal(record.get(106));  // 砂3137细度
            BigDecimal sandBulkDensity1622B = new BigDecimal(record.get(107));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622B = new BigDecimal(record.get(108));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622B = new BigDecimal(record.get(109));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622B = record.get(110);  //砂3137 粒径分布(mm)
            int regionSand1622B = Integer.parseInt(record.get(111));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622B = sandFineness1622B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622B = sandBulkDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622B = sandCompactDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622B = sandApparentDensity1622B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622B = sandModel1622B + "-" + sandFineness1622B + "-" + sandBulkDensity1622B + "-" + sandCompactDensity1622B + "-" + sandApparentDensity1622B + "-"
                    + sandParticleSizeDistribution1622B + "-" + regionSand1622B;
            System.out.println("key: " + keySand2330B);


            Integer sand1622BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622B)) {
                sand1622BId = sysSandMap.get(keySand1622B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand1622BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622B);
                sysSand.setFineness(sandFineness1622B);
                sysSand.setBulkDensity(sandBulkDensity1622B);
                sysSand.setCompactDensity(sandCompactDensity1622B);
                sysSand.setApparentDensity(sandApparentDensity1622B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622B);
                sysSand.setRegionName(regionSand1622B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand1622B, sysSand);
                sand1622BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand1622BId);
            }


            /*砂0475*/
            // String sand0475 = record.get(112);//砂3137参量

            BigDecimal sand0475 = new BigDecimal(record.get(112));// 石头5-10掺量
            sand0475 = sand0475.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel0475 = record.get(113);  // 砂3137型号
            BigDecimal sandFineness0475 = new BigDecimal(record.get(114));  // 砂3137细度
            BigDecimal sandBulkDensity0475 = new BigDecimal(record.get(115));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity0475 = new BigDecimal(record.get(116));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity0475 = new BigDecimal(record.get(117));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution0475 = record.get(118);  //砂3137 粒径分布(mm)
            int regionSand0475 = Integer.parseInt(record.get(119));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness0475 = sandFineness0475.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity0475 = sandBulkDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity0475 = sandCompactDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity0475 = sandApparentDensity0475.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand0475 = sandModel0475 + "-" + sandFineness0475 + "-" + sandBulkDensity0475 + "-" + sandCompactDensity0475 + "-" + sandApparentDensity0475 + "-"
                    + sandParticleSizeDistribution0475 + "-" + regionSand0475;
            System.out.println("key: " + keySand2330B);


            Integer sand0475Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand0475)) {
                sand0475Id = sysSandMap.get(keySand0475).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand0475Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel0475);
                sysSand.setFineness(sandFineness0475);
                sysSand.setBulkDensity(sandBulkDensity0475);
                sysSand.setCompactDensity(sandCompactDensity0475);
                sysSand.setApparentDensity(sandApparentDensity0475);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution0475);
                sysSand.setRegionName(regionSand0475);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand0475, sysSand);
                sand0475Id = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand0475Id);
            }

            /*砂09*/
            //String sand09 = record.get(120);//砂3137参量

            BigDecimal sand09 = new BigDecimal(record.get(120));// 石头5-10掺量
            sand09 = sand09.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel09 = record.get(121);  // 砂3137型号
            BigDecimal sandFineness09 = new BigDecimal(record.get(122));  // 砂3137细度
            BigDecimal sandBulkDensity09 = new BigDecimal(record.get(123));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity09 = new BigDecimal(record.get(124));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity09 = new BigDecimal(record.get(125));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution09 = record.get(126);  //砂3137 粒径分布(mm)
            int regionSand09 = Integer.parseInt(record.get(127));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness09 = sandFineness09.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity09 = sandBulkDensity09.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity09 = sandCompactDensity09.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity09 = sandApparentDensity09.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand09 = sandModel09 + "-" + sandFineness09 + "-" + sandBulkDensity09 + "-" + sandCompactDensity09 + "-" + sandApparentDensity09 + "-"
                    + sandParticleSizeDistribution09 + "-" + regionSand09;
            System.out.println("key: " + keySand09);


            Integer sand09Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand09)) {
                sand09Id = sysSandMap.get(keySand09).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand09Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel09);
                sysSand.setFineness(sandFineness09);
                sysSand.setBulkDensity(sandBulkDensity09);
                sysSand.setCompactDensity(sandCompactDensity09);
                sysSand.setApparentDensity(sandApparentDensity09);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution09);
                sysSand.setRegionName(regionSand09);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand09, sysSand);
                sand09Id = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand09Id);
            }

            /* 石粉*/

            // String otherAdmixturesStonePowder = record.get(128);//石粉用量
            BigDecimal otherAdmixturesStonePowder = new BigDecimal(record.get(128));// 石头5-10掺量
            otherAdmixturesStonePowder = otherAdmixturesStonePowder.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String otherAdmixturesModel = record.get(129);//型号

            BigDecimal otherAdmixturesFineness = new BigDecimal(record.get(130));//细度
            BigDecimal otherAdmixturesMoistureContent = new BigDecimal(record.get(131));//含水量
            BigDecimal otherAdmixturesActivityIndex28d = new BigDecimal(record.get(132));//28天活性指数(%)

            int otherAdmixturesRegionName = Integer.parseInt(record.get(133));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            otherAdmixturesFineness = otherAdmixturesFineness.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesMoistureContent = otherAdmixturesMoistureContent.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesActivityIndex28d = otherAdmixturesActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String otherAdmixturesKey = otherAdmixturesModel + "-" + otherAdmixturesFineness + "-" + otherAdmixturesMoistureContent + "-" + otherAdmixturesActivityIndex28d + "-" + otherAdmixturesRegionName;
            System.out.println("key" + otherAdmixturesKey);


            Integer otherAdmixturesId;
            // 判断是否存在该记录
            if (sysOtherAdmixturesMap.containsKey(otherAdmixturesKey)) {
                otherAdmixturesId = sysOtherAdmixturesMap.get(otherAdmixturesKey).getAdmixturesId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据otherAdmixturesId" + otherAdmixturesId);
            } else {


                SysOtherAdmixtures sysOtherAdmixtures = new SysOtherAdmixtures();
                sysOtherAdmixtures.setModel(otherAdmixturesModel);
                sysOtherAdmixtures.setFineness(otherAdmixturesFineness);
                sysOtherAdmixtures.setMoistureContent(otherAdmixturesMoistureContent);
                sysOtherAdmixtures.setActivityIndex28d(otherAdmixturesActivityIndex28d);
                sysOtherAdmixtures.setRegionName(otherAdmixturesRegionName);
                sysOtherAdmixtures.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysOtherAdmixtures.setId(IdUtils.generateRandomNumber());

                sysOtherAdmixturesService.save(sysOtherAdmixtures);
                sysOtherAdmixturesMap.put(otherAdmixturesKey, sysOtherAdmixtures);

                otherAdmixturesId = sysOtherAdmixtures.getAdmixturesId();
                System.out.println("新增砂头数据otherAdmixturesId，id = " + otherAdmixturesId);
            }

            /*矿粉*/
            //  String mineralPowder = record.get(134);//矿粉掺量
            BigDecimal mineralPowder = new BigDecimal(record.get(134));// 石头5-10掺量
            mineralPowder = mineralPowder.setScale(2, RoundingMode.HALF_UP);


            String mineralPowderModel = record.get(135);//矿粉型号
            String mineralPowderSlagGrade = record.get(136);//矿粉等级

            BigDecimal mineralPowderFineness = new BigDecimal(record.get(137));//细度(%)
            BigDecimal mineralPowderMoistureContent = new BigDecimal(record.get(138));//含水量
            BigDecimal mineralPowderActivityIndex28d = new BigDecimal(record.get(139));//28天活性指数(%)
            int mineralPowderRegionName = Integer.parseInt(record.get(140));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            mineralPowderFineness = mineralPowderFineness.setScale(2, RoundingMode.HALF_UP);
            mineralPowderMoistureContent = mineralPowderMoistureContent.setScale(2, RoundingMode.HALF_UP);
            mineralPowderActivityIndex28d = mineralPowderActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            String keyMineralPowder = mineralPowderModel + "-" + mineralPowderSlagGrade + "-" + mineralPowderFineness + "-" + mineralPowderMoistureContent + "-" + mineralPowderActivityIndex28d + "-" + mineralPowderRegionName;
            Integer mineralPowderId;
            // 判断是否存在该记录
            if (MineralPowderMap.containsKey(keyMineralPowder)) {
                mineralPowderId = MineralPowderMap.get(keyMineralPowder).getPowderId();  // 使用正确的字段名称
                System.out.println("数据库已经存在矿粉数据mineralPowderId" + mineralPowderId);
            } else {

                SysMineralPowder powder = new SysMineralPowder();
                powder.setModel(mineralPowderModel);
                powder.setSlagGrade(mineralPowderSlagGrade);
                powder.setFineness(mineralPowderFineness);
                powder.setMoistureContent(mineralPowderMoistureContent);
                powder.setActivityIndex28d(mineralPowderActivityIndex28d);
                powder.setRegionName(mineralPowderRegionName);
                powder.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                powder.setId(IdUtils.generateRandomNumber());

                sysMineralPowderService.save(powder);
                MineralPowderMap.put(otherAdmixturesKey, powder);

                mineralPowderId = powder.getPowderId();

                System.out.println("新增矿粉数据mineralPowderId，id = " + mineralPowderId);
            }

            /*粉煤灰*/
            //String flyash = record.get(141);//粉煤灰掺量

            BigDecimal flyash = new BigDecimal(record.get(141));// 石头5-10掺量
            flyash = flyash.setScale(2, RoundingMode.HALF_UP);


            String flyashModel = record.get(142);//粉煤灰型号
            String flyashfactoryGrade = record.get(143);//粉煤灰出厂等级

            BigDecimal flyashFineness = new BigDecimal(record.get(144));//粉煤灰细度(%)
            BigDecimal flyashMoistureContent = new BigDecimal(record.get(145));//粉煤灰含水量
            BigDecimal flyashActivityIndex28d = new BigDecimal(record.get(146));//粉煤灰28天活性指数(%)
            int flyashRegionName = Integer.parseInt(record.get(147));//粉煤灰来源地区

            // 确保所有 BigDecimal 保留两位小数
            flyashFineness = flyashFineness.setScale(2, RoundingMode.HALF_UP);
            flyashMoistureContent = flyashMoistureContent.setScale(2, RoundingMode.HALF_UP);
            flyashActivityIndex28d = flyashActivityIndex28d.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyFlyash = flyashModel + "-" + flyashfactoryGrade + "-" + flyashFineness + "-" + flyashMoistureContent + "-" + flyashActivityIndex28d + "-" + flyashRegionName;


            Integer flyashId;
            // 判断是否存在该记录
            if (flyashMap.containsKey(keyFlyash)) {
                flyashId = flyashMap.get(keyFlyash).getFlyashId();
                System.out.println("数据库已经存在矿粉数据flyashId" + flyashId);
            } else {

                SysFlyash sysFlyash = new SysFlyash();
                sysFlyash.setGrade(flyashModel);
                sysFlyash.setFactoryGrade(flyashfactoryGrade);
                sysFlyash.setFineness(flyashFineness);
                sysFlyash.setMoistureContent(flyashMoistureContent);
                sysFlyash.setActivityIndex28d(flyashActivityIndex28d);
                sysFlyash.setRegionName(flyashRegionName);
                sysFlyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysFlyash.setId(IdUtils.generateRandomNumber());
                sysFlyashService.save(sysFlyash);

                flyashMap.put(keyFlyash, sysFlyash);
                flyashId = sysFlyash.getFlyashId();


                System.out.println("新增矿粉数据flyashId，id = " + flyashId);
            }


            /*减水剂*/

            // String waterReducer = record.get(148);//减水剂参量
            BigDecimal waterReducer = new BigDecimal(record.get(148));// 石头5-10掺量
            waterReducer = waterReducer.setScale(2, RoundingMode.HALF_UP);


            String WaterReducermodel = record.get(149);//减水剂型号

            BigDecimal WaterReducersolidContent = new BigDecimal(record.get(150));//含固量(%)
            BigDecimal WaterReducercementPasteFlow = new BigDecimal(record.get(151));//水泥净浆流动度(mm)
            BigDecimal WaterReducerreducingRate = new BigDecimal(record.get(152));//减水率

            String WaterReducerRegionName = record.get(153);//来源地区

            // 确保所有 BigDecimal 保留两位小数
            WaterReducersolidContent = WaterReducersolidContent.setScale(2, RoundingMode.HALF_UP);
            WaterReducercementPasteFlow = WaterReducercementPasteFlow.setScale(2, RoundingMode.HALF_UP);
            WaterReducerreducingRate = WaterReducerreducingRate.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyWaterReducer = WaterReducermodel + "-" + WaterReducersolidContent + "-" + WaterReducercementPasteFlow + "-" + WaterReducerreducingRate + "-" + WaterReducerRegionName;
            System.out.println("减水剂插入数据" + keyWaterReducer);
            Integer waterReducerId;
            if (sysWaterReducerMap.containsKey(keyWaterReducer)) {
                waterReducerId = sysWaterReducerMap.get(keyWaterReducer).getReducerId();
                System.out.println("减水剂 记录已存在（字段完全相同），跳过插入: " + waterReducerId);
            } else {

                SysWaterReducer sysWaterReducer = new SysWaterReducer();
                sysWaterReducer.setModel(WaterReducermodel);
                sysWaterReducer.setSolidContent(WaterReducersolidContent);
                sysWaterReducer.setCementPasteFlow(WaterReducercementPasteFlow);
                sysWaterReducer.setReducingRate(WaterReducerreducingRate);
                sysWaterReducer.setSourceName(WaterReducerRegionName);

                sysWaterReducer.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysWaterReducer.setId(IdUtils.generateRandomNumber());
                sysWaterReducerService.save(sysWaterReducer);

                sysWaterReducerMap.put(keyWaterReducer, sysWaterReducer);

                waterReducerId = sysWaterReducer.getReducerId();


                System.out.println("新增减水剂数据reducerId，id = " + waterReducerId);
            }

            /*增效剂*/
            //  String efficiencyAgent = record.get(154);//增效剂掺量

            BigDecimal efficiencyAgent = new BigDecimal(record.get(154));// 石头5-10掺量
            efficiencyAgent = efficiencyAgent.setScale(2, RoundingMode.HALF_UP);


            String efficiencyAgentModel = record.get(155);//增效剂型号
            String efficiencyAgentRegionName = record.get(156);//增效剂来源

            String efficiencyAgentKey = efficiencyAgentModel + "-" + efficiencyAgentRegionName;
            Integer efficiencyAgentId;
            if (efficiencyAgentMap.containsKey(efficiencyAgentKey)) {
                efficiencyAgentId = efficiencyAgentMap.get(efficiencyAgentKey).getAgentId();
                System.out.println("记录已存在（字段完全相同），跳过插入: " + efficiencyAgentId);
            } else {
                SysEfficiencyAgent sysEfficiencyAgent = new SysEfficiencyAgent();
                sysEfficiencyAgent.setModel(efficiencyAgentModel);
                sysEfficiencyAgent.setSourceName(efficiencyAgentRegionName);
                sysEfficiencyAgent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysEfficiencyAgent.setDeleteTime(0);
                sysEfficiencyAgent.setId(IdUtils.generateRandomNumber());

                sysEfficiencyAgentService.save(sysEfficiencyAgent);

                efficiencyAgentMap.put(efficiencyAgentKey, sysEfficiencyAgent);
                efficiencyAgentId = sysEfficiencyAgent.getAgentId();


                System.out.println("新增增效剂数据efficiencyAgentId，id = " + efficiencyAgentId);
            }


            // String swellinAagent = record.get(157);//膨胀剂掺量型号
            BigDecimal swellinAagent = new BigDecimal(record.get(157));// 石头5-10掺量
            swellinAagent = swellinAagent.setScale(2, RoundingMode.HALF_UP);


            String swellingAgentmodel = record.get(158);//型号
            String swellingAgentRegionName = record.get(159);//来源地区


            // 构造一个唯一的键
            String keySwellingagent = swellingAgentmodel + "-" + swellingAgentRegionName;
            System.out.println("哈哈哈key" + key);
            // 判断是否存在该记录

            Integer sysSwellingId;
            if (SysSwellingMap.containsKey(keySwellingagent)) {
                sysSwellingId = SysSwellingMap.get(keySwellingagent).getSwellingagentId();
                System.out.println("记录已存在（字段完全相同），跳过插入: " + sysSwellingId);
            } else {
                SysSwellingagent sysSwellingagent = new SysSwellingagent();
                sysSwellingagent.setModel(swellingAgentmodel);
                sysSwellingagent.setSourceName(swellingAgentRegionName);
                sysSwellingagent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysSwellingagent.setDeleteTime(0);
                sysSwellingagent.setId(IdUtils.generateRandomNumber());

                sysSwellingagentService.save(sysSwellingagent);
                SysSwellingMap.put(keySwellingagent, sysSwellingagent);
                sysSwellingId = sysSwellingagent.getSwellingagentId();

                System.out.println("新增膨胀剂数据sysSwellingId，id = " + sysSwellingId);
            }


            SysMechanicalPerformance sysMechanicalPerformance = new SysMechanicalPerformance();
            sysMechanicalPerformance.setCementId(cementId);//1
            sysMechanicalPerformance.setStone510Id(stone510Id);//2
            sysMechanicalPerformance.setStone525Id(stone525Id);//3
            sysMechanicalPerformance.setStone2040Id(stone2040Id);//4
            sysMechanicalPerformance.setStone1020Id(stone1020Id);//5
            sysMechanicalPerformance.setStone1030Id(stone1030Id);//6
            sysMechanicalPerformance.setStone010Id(stone010Id);//7
            sysMechanicalPerformance.setStone2031Id(stone20315Id);//8
            sysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);//9
            sysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);//10
            sysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);//11
            sysMechanicalPerformance.setSandMech2330MedId(sand2330BId);//12
            sysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);//13
            sysMechanicalPerformance.setSandMech1622FineId(sand1622BId);//14
            sysMechanicalPerformance.setSandMech0475Id(sand0475Id);//15
            sysMechanicalPerformance.setSandMech09Id(sand09Id);//16
            sysMechanicalPerformance.setStonePowderId(otherAdmixturesId);//17
            sysMechanicalPerformance.setMineralPowderId(mineralPowderId);//18
            sysMechanicalPerformance.setFlyAshId(flyashId);//19
            sysMechanicalPerformance.setWaterReducerId(waterReducerId);//20
            sysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);//21
            sysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22


            batchInsertList.add(sysMechanicalPerformance);//


            //插入力学性能
            // 获取所有已存在的力学性能数据
            LambdaQueryWrapper<SysMechanicalPerformance> wrapperSysMechanicalPerformance = new LambdaQueryWrapper<>();
            List<SysMechanicalPerformance> listwrapperSysMechanicalPerformance = sysMechanicalPerformanceService.list(wrapperSysMechanicalPerformance);
            Map<String, SysMechanicalPerformance> wrapperSysMechanicalPerformanceMap = new HashMap<>();
            // 将数据库中的所有数据按唯一组合键存入 Map
            for (SysMechanicalPerformance sysCement : listwrapperSysMechanicalPerformance) {
                String keySysMechanicalPerformance =
                        sysCement.getCementId() + "-" +
                                sysCement.getStone510Id() + "-" +
                                sysCement.getStone525Id() + "-" +
                                sysCement.getStone2040Id() + "-" +
                                sysCement.getStone1020Id() + "-" +
                                sysCement.getStone1030Id() + "-" +
                                sysCement.getStone010Id() + "-" +
                                sysCement.getStone2031Id() + "-" +
                                sysCement.getSandRiverCoarse3137Id() + "-" +
                                sysCement.getSandRiver2330MedId() + "-" +
                                sysCement.getSandRiver1622FineId() + "-" +
                                sysCement.getSandMech2330MedId() + "-" +
                                sysCement.getSandMech3137CoarseId() + "-" +
                                sysCement.getSandMech1622FineId() + "-" +
                                sysCement.getSandMech0475Id() + "-" +
                                sysCement.getSandMech09Id() + "-" +
                                sysCement.getStonePowderId() + "-" +
                                sysCement.getMineralPowderId() + "-" +
                                sysCement.getFlyAshId() + "-" +
                                sysCement.getWaterReducerId() + "-" +
                                sysCement.getEfficiencyAgentId() + "-" +
                                sysCement.getExpansionAgentId() + "-" +

                                sysCement.getWater() + "-" +
                                sysCement.getCement() + "-" +
                                sysCement.getStone510() + "-" +
                                sysCement.getStone525() + "-" +
                                sysCement.getStone2040() + "-" +
                                sysCement.getStone1020() + "-" +
                                sysCement.getStone1030() + "-" +
                                sysCement.getStone010() + "-" +
                                sysCement.getStoneCoarse20315() + "-" +
                                sysCement.getSandRiverCoarse3137() + "-" +
                                sysCement.getSandRiver2330Med() + "-" +
                                sysCement.getSandRiver1622Fine() + "-" +
                                sysCement.getSandMech2330Med() + "-" +
                                sysCement.getSandMech3137Coarse() + "-" +
                                sysCement.getSandMech1622Fine() + "-" +
                                sysCement.getSandMech0475() + "-" +
                                sysCement.getSandMech09() + "-" +
                                sysCement.getStonePowder() + "-" +
                                sysCement.getMineralPowder() + "-" +
                                sysCement.getFlyAsh() + "-" +
                                sysCement.getWaterReducer() + "-" +
                                sysCement.getEfficiencyAgent() + "-" +
                                sysCement.getExpansionAgent() + "-" +
                                sysCement.getRegion() + "-" +
                                sysCement.getProductionDate() + "-" +
                                sysCement.getStrengthGrade() + "-" +
                                sysCement.getCompressive3d() + "-" +
                                sysCement.getCompressive7d() + "-" +
                                sysCement.getCompressive28d();
                wrapperSysMechanicalPerformanceMap.put(keySysMechanicalPerformance, sysCement);  // 使用一个唯一的组合键作为 map 的 key
            }
            System.out.println("数据库中的key" + wrapperSysMechanicalPerformanceMap);  // 打印生成的 key
            // 构建新的唯一键
            String keySysMechanicalPerformance = cementId + "-" + stone510Id + "-" + stone525Id + "-" + stone2040Id + "-" + stone1020Id + "-"
                    + stone1030Id + "-" + stone010Id + "-" + stone20315Id + "-" + sand3137Id + "-" + sand2330Id + "-"
                    + sand1622Id + "-" + sand2330BId + "-" + sand3137BId + "-" + sand1622BId + "-" + sand0475Id + "-"
                    + sand09Id + "-" + otherAdmixturesId + "-" + mineralPowderId + "-" + flyashId + "-"
                    + waterReducerId + "-" + efficiencyAgentId + "-" + sysSwellingId + "-" + water + "-" + cement
                    + "-" + stone510 + "-" + stone525 + "-" + stone2040 + "-" + stone1020 + "-" + stone1030 + "-" + stone010 + "-" +
                    stone20315 + "-" + sand3137 + "-" + sand2330 + "-" + sand1622 + "-" + sand2330B + "-" + sand3137B + "-" + sand1622B + "-" + sand0475 + "-" +
                    sand09 + "-" + otherAdmixturesStonePowder + "-" + mineralPowder + "-" + flyash + "-" + waterReducer + "-" + efficiencyAgent + "-" + swellinAagent + "-" +
                    regiona + "-" + productionDate + "-" + strengthGrade + "-" + compressive3d + "-" + compressive7d + "-" + compressive28d;


            System.out.println("现在的key" + keySysMechanicalPerformance);
            // 检查是否已经存在相同的力学性能数据
            if (wrapperSysMechanicalPerformanceMap.containsKey(keySysMechanicalPerformance)) {
                // 数据已存在，跳过插入
                System.out.println("力学性能数据已存在，跳过啦哈哈哈哈哈");
            } else {
                // 数据不存在，插入新数据
                SysMechanicalPerformance newSysMechanicalPerformance = new SysMechanicalPerformance();
                newSysMechanicalPerformance.setCementId(cementId);
                newSysMechanicalPerformance.setStone510Id(stone510Id);
                newSysMechanicalPerformance.setStone525Id(stone525Id);
                newSysMechanicalPerformance.setStone2040Id(stone2040Id);
                newSysMechanicalPerformance.setStone1020Id(stone1020Id);
                newSysMechanicalPerformance.setStone1030Id(stone1030Id);
                newSysMechanicalPerformance.setStone010Id(stone010Id);
                newSysMechanicalPerformance.setStone2031Id(stone20315Id);
                newSysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);
                newSysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);
                newSysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);
                newSysMechanicalPerformance.setSandMech2330MedId(sand2330BId);
                newSysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);
                newSysMechanicalPerformance.setSandMech1622FineId(sand1622BId);
                newSysMechanicalPerformance.setSandMech0475Id(sand0475Id);
                newSysMechanicalPerformance.setSandMech09Id(sand09Id);
                newSysMechanicalPerformance.setStonePowderId(otherAdmixturesId);
                newSysMechanicalPerformance.setMineralPowderId(mineralPowderId);
                newSysMechanicalPerformance.setFlyAshId(flyashId);
                newSysMechanicalPerformance.setWaterReducerId(waterReducerId);
                newSysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);
                newSysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22

                newSysMechanicalPerformance.setWater(water);
                newSysMechanicalPerformance.setCement(cement);
                newSysMechanicalPerformance.setStone510(stone510);
                newSysMechanicalPerformance.setStone525(stone525);
                newSysMechanicalPerformance.setStone2040(stone2040);
                newSysMechanicalPerformance.setStone1020(stone1020);
                newSysMechanicalPerformance.setStone1030(stone1030);
                newSysMechanicalPerformance.setStone010(stone010);
                newSysMechanicalPerformance.setStoneCoarse20315(stone20315);
                newSysMechanicalPerformance.setSandRiverCoarse3137(sand3137);
                newSysMechanicalPerformance.setSandRiver2330Med(sand2330);
                newSysMechanicalPerformance.setSandRiver1622Fine(sand1622);
                newSysMechanicalPerformance.setSandMech2330Med(sand2330B);
                newSysMechanicalPerformance.setSandMech3137Coarse(sand3137B);

                newSysMechanicalPerformance.setSandMech1622Fine(sand1622B);
                newSysMechanicalPerformance.setSandMech0475(sand0475);
                newSysMechanicalPerformance.setSandMech09(sand09);

                newSysMechanicalPerformance.setStonePowder(otherAdmixturesStonePowder);

                newSysMechanicalPerformance.setMineralPowder(mineralPowder);
                newSysMechanicalPerformance.setFlyAsh(flyash);
                newSysMechanicalPerformance.setWaterReducer(waterReducer);

                newSysMechanicalPerformance.setEfficiencyAgent(efficiencyAgent);
                newSysMechanicalPerformance.setExpansionAgent(swellinAagent);

                /* 掺量结束*/

                newSysMechanicalPerformance.setRegion(regiona);
                newSysMechanicalPerformance.setProductionDate(productionDate);
                newSysMechanicalPerformance.setStrengthGrade(strengthGrade);


                newSysMechanicalPerformance.setCompressive3d(compressive3d);
                newSysMechanicalPerformance.setCompressive7d(compressive7d);
                newSysMechanicalPerformance.setCompressive28d(compressive28d);
                newSysMechanicalPerformance.setCreateTime(LocalDateTime.now());
                // 插入新数据
                sysMechanicalPerformanceService.save(newSysMechanicalPerformance);
                System.out.println("力学性能数据不存在，已插入哈哈哈哈哈");
            }


        }


        return AjaxResult.success();
    }


    public String saveExcelToLocal(MultipartFile file) throws IOException {
        // 文件保存目录
        String baseDir = uploadDir;
        File dir = new File(baseDir);
        if (!dir.exists()) {
            dir.mkdirs();
        }

        // 生成唯一文件名
        String originalFilename = file.getOriginalFilename();
        String fileName = UUID.randomUUID() + "_" + originalFilename;
        File targetFile = new File(baseDir + fileName);

        // 保存文件
        file.transferTo(targetFile);

        return targetFile.getAbsolutePath(); // 返回路径存入数据库
    }


    // 工具方法：将 Cell 转为字符串
    private String getCellValue(Cell cell) {
        if (cell == null) {
            return "";
        }

        switch (cell.getCellType()) {
            case STRING:
                return cell.getStringCellValue().trim();
            case NUMERIC:
                if (DateUtil.isCellDateFormatted(cell)) {
                    // 格式化日期为 yyyy-MM-dd
                    Date date = cell.getDateCellValue();
                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
                    return sdf.format(date);
                }
                return String.valueOf(cell.getNumericCellValue());
            case BOOLEAN:
                return String.valueOf(cell.getBooleanCellValue());
            case FORMULA:
                try {
                    return cell.getStringCellValue();
                } catch (IllegalStateException e) {
                    return String.valueOf(cell.getNumericCellValue());
                }
            default:
                return "";
        }
    }

    //校验力学性能表     7：力学性能数据  上传的excel
    private AjaxResult checkMechanicalPerformanceV3(List<List<String>> data, String savedPath, String name) {
//        if (data == null || data.size() <= 1) {
//            return AjaxResult.error("请上传包含至少一条数据的文件");
//        }
        // 校验之前去掉表头列
        // data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);


        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }


        for (int i = 0; i < data.size(); i++) {

            System.out.println("我是data数据" + data);


            List<String> row = data.get(i);


            String region = row.get(0); //地区
            String productionDate = row.get(1);//生产日期
            String strengthGrade = row.get(2);//强度等级
            String compressive3d = row.get(3);//3天抗压强度(MPa)
            String compressive7d = row.get(4);//7天抗压强度(MPa)
            String compressive28d = row.get(5);//28天抗压强度(MPa)
            String water = row.get(6);//水掺量(kg/m³)
            String cement = row.get(7);//水泥掺量(kg/m³)

            /*水泥*/
            String cementModel = row.get(8);//水泥型号
            String cementCao = row.get(9);//水泥CaO含量
            String cementSio2 = row.get(10);//水泥SiO2含量
            String cementAl2o3 = row.get(11);//水泥Al2O3含量
            String cementCompressive = row.get(12);//强度等级
            String cementStrengthGrade = row.get(13);//28天
            String cementRegionName = row.get(14);//水泥地区


            String stone510 = row.get(15); //掺量  石头5-10
            String model = row.get(16); //型号  石头5-10
            String stoneSpecification = row.get(17);//石子规格   石头5-10
            String stackingDensity = row.get(18);//堆积密度    石头5-10
            String compactDensity = row.get(19);//紧密密度  石头5-10
            String bulkdensity = row.get(20);//表观密度      石头5-10
            String regionNamestone510 = row.get(21);//来源地区      石头5-10


            String stone525 = row.get(22); //掺量  石头5-25
            String model525 = row.get(23); //型号  石头5-25
            String stoneSpecification525 = row.get(24);//石子规格   石头5-25
            String stackingDensity525 = row.get(25);//堆积密度    石头5-25
            String compactDensity525 = row.get(26);//紧密密度  石头5-25
            String bulkdensity525 = row.get(27);//表观密度      石头5-25
            String regionNamestone525 = row.get(28);//来源地区      石头5-25


            String stone2040 = row.get(29); //掺量  石头20-40mm
            String model2040 = row.get(30); //型号  石头20-40mm
            String stoneSpecification2040 = row.get(31);//石子规格   石头20-40mm
            String stackingDensity2040 = row.get(32);//堆积密度    石头20-40mm
            String compactDensity2040 = row.get(33);//紧密密度  石头20-40mm
            String bulkdensity2040 = row.get(34);//表观密度      石头20-40mm
            String regionNamestone2040 = row.get(35);//来源地区      石头20-40mm


            String stone1020 = row.get(36); //掺量  石头20-40mm
            String model1020 = row.get(37); //型号  石头20-40mm
            String stoneSpecification1020 = row.get(38);//石子规格   石头20-40mm
            String stackingDensity1020 = row.get(39);//堆积密度    石头20-40mm
            String compactDensity1020 = row.get(40);//紧密密度  石头20-40mm
            String bulkdensity1020 = row.get(41);//表观密度      石头20-40mm
            String regionNamestone1020 = row.get(42);//来源地区      石头20-40mm


            String stone1030 = row.get(43); //掺量  石头10-30mm
            String model1030 = row.get(44); //型号  石头10-30mm
            String stoneSpecification1030 = row.get(45);//石子规格   石头10-30mm
            String stackingDensity1030 = row.get(46);//堆积密度    石头10-30mm
            String compactDensity1030 = row.get(47);//紧密密度  石头10-30mm
            String bulkdensity1030 = row.get(48);//表观密度      石头10-30mm
            String regionNamestone1030 = row.get(49);//来源地区      石头10-30mm


            String stone010 = row.get(50); //掺量  石头0-10mm
            String model010 = row.get(51); //型号  石头10-30mm
            String stoneSpecification010 = row.get(52);//石子规格   石头10-30mm
            String stackingDensity010 = row.get(53);//堆积密度    石头10-30mm
            String compactDensity010 = row.get(54);//紧密密度  石头10-30mm
            String bulkdensity010 = row.get(55);//表观密度      石头10-30mm
            String regionNamestone010 = row.get(56);//来源地区      石头10-30mm


            String stone20315 = row.get(57); //掺量  石头0-10mm
            String model20315 = row.get(58); //型号  石头10-30mm
            String stoneSpecification20315 = row.get(59);//石子规格   石头10-30mm
            String stackingDensity20315 = row.get(60);//堆积密度    石头10-30mm
            String compactDensity20315 = row.get(61);//紧密密度  石头10-30mm
            String bulkdensity20315 = row.get(62);//表观密度      石头10-30mm
            String regionNamestone20315 = row.get(63);//来源地区      石头10-30mm





            /*河砂粗3.1-3.7mm*/
            String sand3137 = row.get(64);//砂掺量

            String model3137 = row.get(65);//型号
            String fineness3137 = row.get(66);//细度
            String bulkDensity3137 = row.get(67);//堆积密度 (kg/m3)
            String compactDensity3137 = row.get(68);//紧密密度 (kg/m3)
            String apparentDensity3137 = row.get(69);//表观密度 (kg/m3)

            String particleSizeDistribution3137 = row.get(70);//粒径分布(mm)
            String regionSandName3137 = row.get(71);



            /*河砂粗砂23-30*/
            String sand2330 = row.get(72);//砂掺量

            String model2330 = row.get(73);//型号
            String fineness2330 = row.get(74);//细度
            String bulkDensity2330 = row.get(75);//堆积密度 (kg/m3)
            String compactDensity2330 = row.get(76);//紧密密度 (kg/m3)
            String apparentDensity2330 = row.get(77);//表观密度 (kg/m3)
            String particleSizeDistribution2330 = row.get(78);//粒径分布(mm)
            String regionSandName2330 = row.get(79);



            /*河砂细16-22mm*/
            String sand1622 = row.get(80);//砂掺量

            String model1622 = row.get(81);//型号
            String fineness1622 = row.get(82);//细度
            String bulkDensity1622 = row.get(83);//堆积密度 (kg/m3)
            String compactDensity1622 = row.get(84);//紧密密度 (kg/m3)
            String apparentDensity1622 = row.get(85);//表观密度 (kg/m3)
            String particleSizeDistribution1622 = row.get(86);//粒径分布(mm)
            String regionSandName1622 = row.get(87);



            /*机制砂中23-30Bmm*/
            String sand2330B = row.get(88);//砂掺量

            String model2330B = row.get(89);//型号
            String fineness2330B = row.get(90);//细度
            String bulkDensity2330B = row.get(91);//堆积密度 (kg/m3)
            String compactDensity2330B = row.get(92);//紧密密度 (kg/m3)
            String apparentDensity2330B = row.get(93);//表观密度 (kg/m3)
            String particleSizeDistribution2330B = row.get(94);//粒径分布(mm)
            String regionSandName2330B = row.get(95);




            /*机制砂粗31-37Bmm*/
            String sand3137B = row.get(96);//砂掺量
            String model3137B = row.get(97);//型号
            String fineness3137B = row.get(98);//细度
            String bulkDensity3137B = row.get(99);//堆积密度 (kg/m3)
            String compactDensity3137B = row.get(100);//紧密密度 (kg/m3)
            String apparentDensity3137B = row.get(101);//表观密度 (kg/m3)
            String particleSizeDistribution3137B = row.get(102);//粒径分布(mm)
            String regionSandName3137B = row.get(103);


            /*机制砂细16-22Bmm*/
            String sand1622B = row.get(104);//砂掺量
            String model1622B = row.get(105);//型号
            String fineness1622B = row.get(106);//细度
            String bulkDensity1622B = row.get(107);//堆积密度 (kg/m3)
            String compactDensity1622B = row.get(108);//紧密密度 (kg/m3)
            String apparentDensity1622B = row.get(109);//表观密度 (kg/m3)
            String particleSizeDistribution1622B = row.get(110);//粒径分布(mm)
            String regionSandName1622B = row.get(111);


            /*机制砂0-4.75mm*/
            String sand0475 = row.get(112);//砂掺量
            String model0475 = row.get(113);//型号
            String fineness0475 = row.get(114);//细度
            String bulkDensity0475 = row.get(115);//堆积密度 (kg/m3)
            String compactDensity0475 = row.get(116);//紧密密度 (kg/m3)
            String apparentDensity0475 = row.get(117);//表观密度 (kg/m3)
            String particleSizeDistribution0475 = row.get(118);//粒径分布(mm)
            String regionSandName0475 = row.get(119);




            /*机制砂0-9mm*/
            String sand09 = row.get(120);//砂掺量
            String model09 = row.get(121);//型号
            String fineness09 = row.get(122);//细度
            String bulkDensity09 = row.get(123);//堆积密度 (kg/m3)
            String compactDensity09 = row.get(124);//紧密密度 (kg/m3)
            String apparentDensity09 = row.get(125);//表观密度 (kg/m3)
            String particleSizeDistribution09 = row.get(126);//粒径分布(mm)
            String regionSandName09 = row.get(127);


            /*石粉*/
            String otherAdmixtures = row.get(128); //掺量
            String modelotherAdmixtures = row.get(129); //型号
            String finenessotherAdmixtures = row.get(130);//细度(%)
            String moistureContentotherAdmixtures = row.get(131);//含水量(%)
            String activityIndex28dOtherAdmixtures = row.get(132);//28天活性指数(%)
            String regionNameOtherAdmixtures = row.get(133);//来源地区



            /*矿粉*/


            String mineralPowder = row.get(134); //矿粉掺量

            String mineralPowdermodel = row.get(135); //型号
            String mineralPowderSlagGrade = row.get(136);//矿粉等级
            String mineralPowderFineness = row.get(137);//细度
            String mineralPowdermoistureContent = row.get(138);//含水量
            String mineralPowderactivityIndex28d = row.get(139);//28天活性指数
            String mineralPowderregionName = row.get(140);//来源地区


            String sysFlyash = row.get(141); //粉煤灰掺量

            String flyashModel = row.get(142); //粉煤灰型号
            String flyashFactoryGrade = row.get(143); //粉煤灰出厂等级
            String flyashFineness = row.get(144);//粉煤灰细度(%)
            String flyashMoistureContent = row.get(145);//粉煤灰含水量(%
            String flyashActivityIndex28d = row.get(146);//粉煤灰28天活性指数(%)
            String flyashRegionName = row.get(147);//粉煤灰来源地区


            String waterReducer = row.get(148);//减水剂掺量
            String waterReducerModel = row.get(149);//减水剂型号
            String waterReducersolidContent = row.get(150);//减水剂含固量(%)
            String waterReducercementPasteFlow = row.get(151);//减水剂水泥净浆流动度(mm)
            String waterReducerreducingRate = row.get(152);//减水剂减水率
            String waterReducerRegionName = row.get(153);//减水剂来源


            String efficiencyAgent = row.get(154);//增效剂掺量
            String efficiencyAgentModel = row.get(155);//增效剂型号
            String efficiencyAgentName = row.get(156);//增效剂来源


            String swellingagentAgent = row.get(157);//膨胀剂掺量
            String swellingagentModel = row.get(158);//膨胀剂型号
            String swellingagentName = row.get(159);//膨胀剂来源


            try {
                Double.parseDouble(compressive3d);
            } catch (NumberFormatException e) {
                return AjaxResult.error("第 " + (i + 1) + " 行：3天抗压强度(MPa) 必须是一个数字");
            }


            Region matched = matchOrInsertRegion(region, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(0, String.valueOf(matched.getId()));

            Region matched14 = matchOrInsertRegion(cementRegionName, fullNameMap);
            if (matched14 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(14, String.valueOf(matched14.getId()));

            Region matchedregionNamestone510 = matchOrInsertRegion(regionNamestone510, fullNameMap);
            if (matchedregionNamestone510 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(21, String.valueOf(matchedregionNamestone510.getId()));

            Region matchedregionNamestone525 = matchOrInsertRegion(regionNamestone525, fullNameMap);
            if (matchedregionNamestone525 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(28, String.valueOf(matchedregionNamestone525.getId()));


            Region matchedregionNamestone2040 = matchOrInsertRegion(regionNamestone2040, fullNameMap);
            if (matchedregionNamestone2040 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(35, String.valueOf(matchedregionNamestone2040.getId()));


            Region matchedregionNamestone1020 = matchOrInsertRegion(regionNamestone1020, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(42, String.valueOf(matchedregionNamestone1020.getId()));


            Region matchedregionNamestone1030 = matchOrInsertRegion(regionNamestone1030, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(49, String.valueOf(matchedregionNamestone1030.getId()));

            Region matchedregionNamestone010 = matchOrInsertRegion(regionNamestone010, fullNameMap);
            if (matchedregionNamestone010 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(56, String.valueOf(matchedregionNamestone010.getId()));


            Region matchedregionNamestone20315 = matchOrInsertRegion(regionNamestone20315, fullNameMap);
            if (matchedregionNamestone20315 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(63, String.valueOf(matchedregionNamestone20315.getId()));


            Region SandName3137 = matchOrInsertRegion(regionSandName3137, fullNameMap);
            if (SandName3137 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(71, String.valueOf(SandName3137.getId()));


            Region SandName2330 = matchOrInsertRegion(regionSandName2330, fullNameMap);
            if (SandName2330 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(79, String.valueOf(SandName2330.getId()));


            Region SandName1622 = matchOrInsertRegion(regionSandName1622, fullNameMap);
            if (SandName1622 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(87, String.valueOf(SandName1622.getId()));

            Region SandName2330B = matchOrInsertRegion(regionSandName2330B, fullNameMap);
            if (SandName2330B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(95, String.valueOf(SandName2330B.getId()));


            Region SandName3137B = matchOrInsertRegion(regionSandName3137B, fullNameMap);
            if (SandName3137B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(103, String.valueOf(SandName3137B.getId()));

            Region SandName1622B = matchOrInsertRegion(regionSandName1622B, fullNameMap);
            if (SandName1622B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(111, String.valueOf(SandName1622B.getId()));


            Region SandName0475 = matchOrInsertRegion(regionSandName0475, fullNameMap);
            if (SandName0475 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(119, String.valueOf(SandName0475.getId()));


            Region SandName09 = matchOrInsertRegion(regionSandName09, fullNameMap);
            if (SandName09 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(127, String.valueOf(SandName09.getId()));


            Region SandName133 = matchOrInsertRegion(regionNameOtherAdmixtures, fullNameMap);
            if (SandName133 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(133, String.valueOf(SandName133.getId()));

            Region SandName140 = matchOrInsertRegion(mineralPowderregionName, fullNameMap);
            if (SandName140 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(140, String.valueOf(SandName140.getId()));


            Region SandName147 = matchOrInsertRegion(flyashRegionName, fullNameMap);
            if (SandName147 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(147, String.valueOf(SandName147.getId()));


        }


        String filePath = saveDataToFile(data, name);
        SysExcelAudit sysExcelAudit = new SysExcelAudit();
        sysExcelAudit.setFilePath(filePath);
        sysExcelAudit.setExcelPath(savedPath);
        sysExcelAudit.setVersion(0);
        sysExcelAudit.setDeleteTime(0);
        sysExcelAudit.setTableName(name);
        sysExcelAudit.setId(IdUtils.generateRandomNumber());
        sysExcelAudit.setCreateTime(LocalDateTime.now());
        sysExcelAudit.setUserId(SecurityUtils.getUserId());
        sysExcelAudit.setType(0);
        sysExcelAuditService.save(sysExcelAudit);


//        ExcelFileHistory excelFileHistory = new ExcelFileHistory();
//        excelFileHistory.setFileName(name);
//        excelFileHistory.setFilePath(filePath);
//        excelFileHistory.setType(0);
//        excelFileHistory.setCreateTime(LocalDateTime.now());
//        excelFileHistoryService.save(excelFileHistory);


        return AjaxResult.success("抗压强度校验通过，地区已处理");
    }

    // 匹配或者插入一个新的地区
    private Region matchOrInsertRegion(String input, Map<String, Region> regionMap) {
        // 使用 "-" 分割输入的地区名称，假设格式为 "省-市-区"
        String[] parts = input.split("-");

        Region province = null;
        Region city = null;
        Region district = null;

        // 获取省份的名称
        String provinceName = parts[0];
        // 根据省的名称从缓存的 regionMap 中获取省份对象
        province = regionMap.get(provinceName);
        // 如果省份不存在，则插入新的省份
        if (province == null) {
            province = insertRegion(provinceName, null, 1); // 1 代表省份的级别
            regionMap.put(provinceName, province); // 将新创建的省份放入缓存
        }

        // 如果输入有市，处理市的部分
        if (parts.length >= 2) {
            // 组合完整的市名称（包括省名）
            String cityFull = provinceName + "-" + parts[1];
            city = regionMap.get(cityFull); // 获取市级对象
            // 如果市级不存在，则插入新的市
            if (city == null) {
                city = insertRegion(parts[1], province.getId(), 2); // 2 代表市的级别
                regionMap.put(cityFull, city); // 将新创建的市放入缓存
            }
        }

        // 如果输入有区，处理区的部分
        if (parts.length == 3) {
            // 组合完整的区名称（包括省市名）
            String districtFull = provinceName + "-" + parts[1] + "-" + parts[2];
            district = regionMap.get(districtFull); // 获取区级对象
            // 如果区级不存在，则插入新的区
            if (district == null) {
                district = insertRegion(parts[2], city.getId(), 3); // 3 代表区的级别
                regionMap.put(districtFull, district); // 将新创建的区放入缓存
            }
        }

        // 根据层级返回最具体的区域，如果有区返回区，否则返回市，若都没有则返回省
        return district != null ? district : (city != null ? city : province);
    }

    // 插入一个新的地区
    private Region insertRegion(String name, Integer parentId, int level) {
        Region region = new Region();
        region.setName(name); // 设置地区名称
        region.setParentId(parentId); // 设置父地区的ID
        region.setLevel(level); // 设置地区的级别，1-省，2-市，3-区

        // 如果没有父地区，说明这是一个顶级区域
        if (parentId == null) {
            region.setFullName(name); // 顶级区域的全名就是它自己
        } else {
            // 否则，构建完整的地区全名（父地区全名 + 当前地区名称）
            Region parent = regionService.getById(parentId); // 从数据库获取父地区对象
            region.setFullName(parent.getFullName() + "-" + name);
        }

        // 设置区域的唯一标识码
        region.setCode("TMP" + System.currentTimeMillis());
        // 设置创建时间
        region.setCreateTime(LocalDateTime.now()); // 使用 Java 8 的日期时间 API
        // 设置版本号
        region.setVersion(1);
        // 设置删除时间标志，0 表示没有删除
        region.setDeleteTime(0);

        // 保存到数据库
        regionService.save(region);
        return region;
    }


    //    @GetMapping("query/excel/audit")
//    public AjaxResult queryExcelAudit() {
//        List<SysExcelAudit> list = sysExcelAuditService.list();
//
//        // Convert SysExcelAudit to SysExcelAuditVO
//        List<SysExcelAuditVO> voList = list.stream().map(audit -> {
//            SysExcelAuditVO vo = new SysExcelAuditVO();
//            BeanUtils.copyProperties(audit, vo);
//
//
//            return vo;
//        }).collect(Collectors.toList());
//
//        return AjaxResult.success(voList);
//    }

    @PostMapping("query/excel/audit")
    public AjaxResult queryExcelAudit(@RequestBody SysExcelAuditDTO sysExcelAuditDTO) {
        List<SysExcelAuditVO> voList = null;
        try {
            // 调用服务层查询数据
            voList = sysExcelAuditService.queryExcelAudit(sysExcelAuditDTO);
        } catch (Exception e) {
            // 打印错误日志
            log.error("查询Excel审计数据失败", e);
            // 返回统一的错误响应
            return AjaxResult.error("查询Excel审计数据失败", e.getMessage());
        }

        // 返回查询结果
        return AjaxResult.success(voList);
    }



    /**
     * 查询是否入库
     * @param sysExcelAuditDTO
     * @return
     */
    @PostMapping("query/excel/audit/is/not/warehouse")
    public AjaxResult queryExcelAuditIsWarehouse(@RequestBody SysExcelAuditDTO sysExcelAuditDTO) {
        List<SysExcelAuditVO> voList = null;
        try {
            // 调用服务层查询数据
            voList = sysExcelAuditService.queryExcelAuditIsWarehouse(sysExcelAuditDTO);
        } catch (Exception e) {
            // 记录错误日志
            log.error("查询Excel审计数据失败: ", e);

            // 返回统一的错误响应
            return AjaxResult.error("查询是否入库失败", e.getMessage());
        }

        // 返回查询结果
        return AjaxResult.success(voList);
    }




    /**
     * 坍落度上载
     *
     * @param file
     * @param name
     * @return
     */

    @PostMapping("/upload/slump/excel")
    @Transactional
    public AjaxResult uploadSlump(@RequestParam("file") MultipartFile file,
                                  @RequestParam("name") String name) {
        List<List<String>> data = new ArrayList<>();

        // 文件类型校验
        String filename = file.getOriginalFilename();
        if (filename == null || !filename.endsWith(".xlsx")) {
            return AjaxResult.error("文件格式错误，请上传 .xlsx 格式的 Excel 文件");
        }

        try (InputStream is = file.getInputStream();
             Workbook workbook = new XSSFWorkbook(is)) {
            Sheet sheet = workbook.getSheetAt(0); // 读取第一个 sheet
            for (Row row : sheet) {
                if (row == null) {
                    continue;
                }
                List<String> rowData = new ArrayList<>();
                for (Cell cell : row) {
                    rowData.add(getCellValue(cell));
                }
                data.add(rowData);
            }


//            // 移除表头
            if (!data.isEmpty()) {
                data.remove(0);
            }
            // 在索引2后插入3个空字符串
            for (List<String> row : data) {
                if (row.size() > 2) {
                    row.add(3, "");
                    row.add(3, "");
                    row.add(3, "");
                } else {
                    // 如果长度不足3，也填充空字符串，保持格式统一
                    while (row.size() <= 2) {
                        row.add("");
                    }
                    row.add("");
                    row.add("");
                    row.add("");
                }
            }

            // 1. 保存原始 Excel 到本地
            String savedPath = saveExcelToLocal(file);


            System.out.println("坍落度dataHHH" + data);
            // 校验数据（方法内部可抛出异常）
            AjaxResult ajaxResult = checkSysSlumpV2(data, savedPath, name);

            return ajaxResult;

        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("读取失败：" + e.getMessage());
        } catch (Exception ex) {
            ex.printStackTrace();
            return AjaxResult.error("校验失败：" + ex.getMessage());
        }
    }


    //校验坍落度表     14：坍落度
    private AjaxResult checkSysSlumpV2(List<List<String>> data, String savedPath, String name) {
        if (data == null || data.size() <= 1) {
            return AjaxResult.error("请上传包含至少一条数据的文件");
        }
        // 校验之前去掉表头列
        data.remove(0); // 去掉表头

        // 查询所有未删除的地区
        LambdaQueryWrapper<Region> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Region::getDeleteTime, 0);
        List<Region> regionList = regionService.list(wrapper);


        // 构建 fullName -> Region 的 Map
        Map<String, Region> fullNameMap = new HashMap<>();
        for (Region r : regionList) {
            fullNameMap.put(r.getFullName(), r);
        }

        for (int i = 0; i < data.size(); i++) {
            System.out.println("我是data数据" + data);

            List<String> row = data.get(i);

//            if (row == null || row.size() != 22) {
//                return AjaxResult.error("第 " + (i + 1) + " 行：必须包含 22个字段");
//            }

            String region = row.get(0); //地区
            String productionDate = row.get(1);//生产日期
            String slump = row.get(2);//坍落度

//            String strengthGrade = row.get(2);//强度等级
//            String compressive3d = row.get(3);//3天抗压强度(MPa)
//            String compressive7d = row.get(4);//7天抗压强度(MPa)
//            String compressive28d = row.get(5);//28天抗压强度(MPa)

            String water = row.get(6);//水掺量(kg/m³)
            String cement = row.get(7);//水泥掺量(kg/m³)

            /*水泥*/
            String cementModel = row.get(8);//水泥型号
            String cementCao = row.get(9);//水泥CaO含量
            String cementSio2 = row.get(10);//水泥SiO2含量
            String cementAl2o3 = row.get(11);//水泥Al2O3含量
            String cementCompressive = row.get(12);//强度等级
            String cementStrengthGrade = row.get(13);//28天
            String cementRegionName = row.get(14);//水泥地区


            String stone510 = row.get(15); //掺量  石头5-10
            String model = row.get(16); //型号  石头5-10
            String stoneSpecification = row.get(17);//石子规格   石头5-10
            String stackingDensity = row.get(18);//堆积密度    石头5-10
            String compactDensity = row.get(19);//紧密密度  石头5-10
            String bulkdensity = row.get(20);//表观密度      石头5-10
            String regionNamestone510 = row.get(21);//来源地区      石头5-10


            String stone525 = row.get(22); //掺量  石头5-25
            String model525 = row.get(23); //型号  石头5-25
            String stoneSpecification525 = row.get(24);//石子规格   石头5-25
            String stackingDensity525 = row.get(25);//堆积密度    石头5-25
            String compactDensity525 = row.get(26);//紧密密度  石头5-25
            String bulkdensity525 = row.get(27);//表观密度      石头5-25
            String regionNamestone525 = row.get(28);//来源地区      石头5-25


            String stone2040 = row.get(29); //掺量  石头20-40mm
            String model2040 = row.get(30); //型号  石头20-40mm
            String stoneSpecification2040 = row.get(31);//石子规格   石头20-40mm
            String stackingDensity2040 = row.get(32);//堆积密度    石头20-40mm
            String compactDensity2040 = row.get(33);//紧密密度  石头20-40mm
            String bulkdensity2040 = row.get(34);//表观密度      石头20-40mm
            String regionNamestone2040 = row.get(35);//来源地区      石头20-40mm


            String stone1020 = row.get(36); //掺量  石头20-40mm
            String model1020 = row.get(37); //型号  石头20-40mm
            String stoneSpecification1020 = row.get(38);//石子规格   石头20-40mm
            String stackingDensity1020 = row.get(39);//堆积密度    石头20-40mm
            String compactDensity1020 = row.get(40);//紧密密度  石头20-40mm
            String bulkdensity1020 = row.get(41);//表观密度      石头20-40mm
            String regionNamestone1020 = row.get(42);//来源地区      石头20-40mm


            String stone1030 = row.get(43); //掺量  石头10-30mm
            String model1030 = row.get(44); //型号  石头10-30mm
            String stoneSpecification1030 = row.get(45);//石子规格   石头10-30mm
            String stackingDensity1030 = row.get(46);//堆积密度    石头10-30mm
            String compactDensity1030 = row.get(47);//紧密密度  石头10-30mm
            String bulkdensity1030 = row.get(48);//表观密度      石头10-30mm
            String regionNamestone1030 = row.get(49);//来源地区      石头10-30mm


            String stone010 = row.get(50); //掺量  石头0-10mm
            String model010 = row.get(51); //型号  石头10-30mm
            String stoneSpecification010 = row.get(52);//石子规格   石头10-30mm
            String stackingDensity010 = row.get(53);//堆积密度    石头10-30mm
            String compactDensity010 = row.get(54);//紧密密度  石头10-30mm
            String bulkdensity010 = row.get(55);//表观密度      石头10-30mm
            String regionNamestone010 = row.get(56);//来源地区      石头10-30mm


            String stone20315 = row.get(57); //掺量  石头0-10mm
            String model20315 = row.get(58); //型号  石头10-30mm
            String stoneSpecification20315 = row.get(59);//石子规格   石头10-30mm
            String stackingDensity20315 = row.get(60);//堆积密度    石头10-30mm
            String compactDensity20315 = row.get(61);//紧密密度  石头10-30mm
            String bulkdensity20315 = row.get(62);//表观密度      石头10-30mm
            String regionNamestone20315 = row.get(63);//来源地区      石头10-30mm





            /*河砂粗3.1-3.7mm*/
            String sand3137 = row.get(64);//砂掺量

            String model3137 = row.get(65);//型号
            String fineness3137 = row.get(66);//细度
            String bulkDensity3137 = row.get(67);//堆积密度 (kg/m3)
            String compactDensity3137 = row.get(68);//紧密密度 (kg/m3)
            String apparentDensity3137 = row.get(69);//表观密度 (kg/m3)

            String particleSizeDistribution3137 = row.get(70);//粒径分布(mm)
            String regionSandName3137 = row.get(71);



            /*河砂粗砂23-30*/
            String sand2330 = row.get(72);//砂掺量

            String model2330 = row.get(73);//型号
            String fineness2330 = row.get(74);//细度
            String bulkDensity2330 = row.get(75);//堆积密度 (kg/m3)
            String compactDensity2330 = row.get(76);//紧密密度 (kg/m3)
            String apparentDensity2330 = row.get(77);//表观密度 (kg/m3)
            String particleSizeDistribution2330 = row.get(78);//粒径分布(mm)
            String regionSandName2330 = row.get(79);



            /*河砂细16-22mm*/
            String sand1622 = row.get(80);//砂掺量

            String model1622 = row.get(81);//型号
            String fineness1622 = row.get(82);//细度
            String bulkDensity1622 = row.get(83);//堆积密度 (kg/m3)
            String compactDensity1622 = row.get(84);//紧密密度 (kg/m3)
            String apparentDensity1622 = row.get(85);//表观密度 (kg/m3)
            String particleSizeDistribution1622 = row.get(86);//粒径分布(mm)
            String regionSandName1622 = row.get(87);



            /*机制砂中23-30Bmm*/
            String sand2330B = row.get(88);//砂掺量

            String model2330B = row.get(89);//型号
            String fineness2330B = row.get(90);//细度
            String bulkDensity2330B = row.get(91);//堆积密度 (kg/m3)
            String compactDensity2330B = row.get(92);//紧密密度 (kg/m3)
            String apparentDensity2330B = row.get(93);//表观密度 (kg/m3)
            String particleSizeDistribution2330B = row.get(94);//粒径分布(mm)
            String regionSandName2330B = row.get(95);




            /*机制砂粗31-37Bmm*/
            String sand3137B = row.get(96);//砂掺量
            String model3137B = row.get(97);//型号
            String fineness3137B = row.get(98);//细度
            String bulkDensity3137B = row.get(99);//堆积密度 (kg/m3)
            String compactDensity3137B = row.get(100);//紧密密度 (kg/m3)
            String apparentDensity3137B = row.get(101);//表观密度 (kg/m3)
            String particleSizeDistribution3137B = row.get(102);//粒径分布(mm)
            String regionSandName3137B = row.get(103);


            /*机制砂细16-22Bmm*/
            String sand1622B = row.get(104);//砂掺量
            String model1622B = row.get(105);//型号
            String fineness1622B = row.get(106);//细度
            String bulkDensity1622B = row.get(107);//堆积密度 (kg/m3)
            String compactDensity1622B = row.get(108);//紧密密度 (kg/m3)
            String apparentDensity1622B = row.get(109);//表观密度 (kg/m3)
            String particleSizeDistribution1622B = row.get(110);//粒径分布(mm)
            String regionSandName1622B = row.get(111);


            /*机制砂0-4.75mm*/
            String sand0475 = row.get(112);//砂掺量
            String model0475 = row.get(113);//型号
            String fineness0475 = row.get(114);//细度
            String bulkDensity0475 = row.get(115);//堆积密度 (kg/m3)
            String compactDensity0475 = row.get(116);//紧密密度 (kg/m3)
            String apparentDensity0475 = row.get(117);//表观密度 (kg/m3)
            String particleSizeDistribution0475 = row.get(118);//粒径分布(mm)
            String regionSandName0475 = row.get(119);




            /*机制砂0-9mm*/
            String sand09 = row.get(120);//砂掺量
            String model09 = row.get(121);//型号
            String fineness09 = row.get(122);//细度
            String bulkDensity09 = row.get(123);//堆积密度 (kg/m3)
            String compactDensity09 = row.get(124);//紧密密度 (kg/m3)
            String apparentDensity09 = row.get(125);//表观密度 (kg/m3)
            String particleSizeDistribution09 = row.get(126);//粒径分布(mm)
            String regionSandName09 = row.get(127);


            /*石粉*/
            String otherAdmixtures = row.get(128); //掺量
            String modelotherAdmixtures = row.get(129); //型号
            String finenessotherAdmixtures = row.get(130);//细度(%)
            String moistureContentotherAdmixtures = row.get(131);//含水量(%)
            String activityIndex28dOtherAdmixtures = row.get(132);//28天活性指数(%)
            String regionNameOtherAdmixtures = row.get(133);//来源地区



            /*矿粉*/


            String mineralPowder = row.get(134); //矿粉掺量

            String mineralPowdermodel = row.get(135); //型号
            String mineralPowderSlagGrade = row.get(136);//矿粉等级
            String mineralPowderFineness = row.get(137);//细度
            String mineralPowdermoistureContent = row.get(138);//含水量
            String mineralPowderactivityIndex28d = row.get(139);//28天活性指数
            String mineralPowderregionName = row.get(140);//来源地区


            String sysFlyash = row.get(141); //粉煤灰掺量

            String flyashModel = row.get(142); //粉煤灰型号
            String flyashFactoryGrade = row.get(143); //粉煤灰出厂等级
            String flyashFineness = row.get(144);//粉煤灰细度(%)
            String flyashMoistureContent = row.get(145);//粉煤灰含水量(%
            String flyashActivityIndex28d = row.get(146);//粉煤灰28天活性指数(%)
            String flyashRegionName = row.get(147);//粉煤灰来源地区


            String waterReducer = row.get(148);//减水剂掺量
            String waterReducerModel = row.get(149);//减水剂型号
            String waterReducersolidContent = row.get(150);//减水剂含固量(%)
            String waterReducercementPasteFlow = row.get(151);//减水剂水泥净浆流动度(mm)
            String waterReducerreducingRate = row.get(152);//减水剂减水率
            String waterReducerRegionName = row.get(153);//减水剂来源


            String efficiencyAgent = row.get(154);//增效剂掺量
            String efficiencyAgentModel = row.get(155);//增效剂型号
            String efficiencyAgentName = row.get(156);//增效剂来源


            String swellingagentAgent = row.get(157);//膨胀剂掺量
            String swellingagentModel = row.get(158);//膨胀剂型号
            String swellingagentName = row.get(159);//膨胀剂来源


            Region matched = matchOrInsertRegion(region, fullNameMap);
            if (matched == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(0, String.valueOf(matched.getId()));

            Region matched14 = matchOrInsertRegion(cementRegionName, fullNameMap);
            if (matched14 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(14, String.valueOf(matched14.getId()));

            Region matchedregionNamestone510 = matchOrInsertRegion(regionNamestone510, fullNameMap);
            if (matchedregionNamestone510 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(21, String.valueOf(matchedregionNamestone510.getId()));

            Region matchedregionNamestone525 = matchOrInsertRegion(regionNamestone525, fullNameMap);
            if (matchedregionNamestone525 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(28, String.valueOf(matchedregionNamestone525.getId()));


            Region matchedregionNamestone2040 = matchOrInsertRegion(regionNamestone2040, fullNameMap);
            if (matchedregionNamestone2040 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(35, String.valueOf(matchedregionNamestone2040.getId()));


            Region matchedregionNamestone1020 = matchOrInsertRegion(regionNamestone1020, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(42, String.valueOf(matchedregionNamestone1020.getId()));


            Region matchedregionNamestone1030 = matchOrInsertRegion(regionNamestone1030, fullNameMap);
            if (matchedregionNamestone1020 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(49, String.valueOf(matchedregionNamestone1030.getId()));

            Region matchedregionNamestone010 = matchOrInsertRegion(regionNamestone010, fullNameMap);
            if (matchedregionNamestone010 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(56, String.valueOf(matchedregionNamestone010.getId()));


            Region matchedregionNamestone20315 = matchOrInsertRegion(regionNamestone20315, fullNameMap);
            if (matchedregionNamestone20315 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(63, String.valueOf(matchedregionNamestone20315.getId()));


            Region SandName3137 = matchOrInsertRegion(regionSandName3137, fullNameMap);
            if (SandName3137 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(71, String.valueOf(SandName3137.getId()));


            Region SandName2330 = matchOrInsertRegion(regionSandName2330, fullNameMap);
            if (SandName2330 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(79, String.valueOf(SandName2330.getId()));


            Region SandName1622 = matchOrInsertRegion(regionSandName1622, fullNameMap);
            if (SandName1622 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(87, String.valueOf(SandName1622.getId()));

            Region SandName2330B = matchOrInsertRegion(regionSandName2330B, fullNameMap);
            if (SandName2330B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(95, String.valueOf(SandName2330B.getId()));


            Region SandName3137B = matchOrInsertRegion(regionSandName3137B, fullNameMap);
            if (SandName3137B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(103, String.valueOf(SandName3137B.getId()));

            Region SandName1622B = matchOrInsertRegion(regionSandName1622B, fullNameMap);
            if (SandName1622B == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(111, String.valueOf(SandName1622B.getId()));


            Region SandName0475 = matchOrInsertRegion(regionSandName0475, fullNameMap);
            if (SandName0475 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(119, String.valueOf(SandName0475.getId()));


            Region SandName09 = matchOrInsertRegion(regionSandName09, fullNameMap);
            if (SandName09 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(127, String.valueOf(SandName09.getId()));


            Region SandName133 = matchOrInsertRegion(regionNameOtherAdmixtures, fullNameMap);
            if (SandName133 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(133, String.valueOf(SandName133.getId()));

            Region SandName140 = matchOrInsertRegion(mineralPowderregionName, fullNameMap);
            if (SandName140 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(140, String.valueOf(SandName140.getId()));


            Region SandName147 = matchOrInsertRegion(flyashRegionName, fullNameMap);
            if (SandName147 == null) {
                return AjaxResult.error("第 " + (i + 1) + " 行：地区创建失败 - " + region);
            }
            row.set(147, String.valueOf(SandName147.getId()));

        }

        String filePath = saveDataToFile(data, name);
        SysExcelAudit sysExcelAudit = new SysExcelAudit();
        sysExcelAudit.setFilePath(filePath);
        sysExcelAudit.setExcelPath(savedPath);
        sysExcelAudit.setVersion(0);
        sysExcelAudit.setDeleteTime(0);
        sysExcelAudit.setTableName(name);
        sysExcelAudit.setId(IdUtils.generateRandomNumber());
        sysExcelAudit.setCreateTime(LocalDateTime.now());
        sysExcelAudit.setUserId(SecurityUtils.getUserId());
        sysExcelAudit.setType(1);
        sysExcelAuditService.save(sysExcelAudit);
        return AjaxResult.success("水泥数据校验通过，地区已处理");
    }


    /**
     * 插入坍落度
     * @param
     * @return
     */
/*
    @PostMapping("/check/slump")
    @Transactional
    public AjaxResult checkSlump(@RequestBody CheckMechanicalPerformanceDTO checkMechanicalPerformanceDTO) {


        LambdaQueryWrapper<SysExcelAudit> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(SysExcelAudit::getId,checkMechanicalPerformanceDTO.getId());
        SysExcelAudit sysExcelAudit = sysExcelAuditService.getOne(wrapper);
        String excelPath = sysExcelAudit.getFilePath();

//            // 移除表头
//            if (!data.isEmpty()) {
//                data.remove(0);
//            }


        // 校验数据（方法内部可抛出异常）
        AjaxResult ajaxResult = saveSysSlumpPerformanceV2(excelPath);


        return ajaxResult;


    }
*/

    /**
     * 插入坍落度
     *
     * @param
     * @return
     */
    @PostMapping("/check/slump")
    @Transactional
    public AjaxResult checkSlump(@RequestBody CheckMechanicalPerformanceDTO checkMechanicalPerformanceDTO) {
        Integer id = checkMechanicalPerformanceDTO.getId();
        Integer status = checkMechanicalPerformanceDTO.getStatus();
        String reason = checkMechanicalPerformanceDTO.getReason();

        // 查找审核记录
        SysExcelAudit sysExcelAudit = sysExcelAuditService.getOne(
                new LambdaQueryWrapper<SysExcelAudit>().eq(SysExcelAudit::getId, id)
        );

        if (sysExcelAudit == null) {
            return AjaxResult.error("审核记录不存在");
        }
        Integer type = sysExcelAudit.getType();

        if (type != 1) {
            return AjaxResult.error("不是坍落度数据");
        }

        String excelPath = sysExcelAudit.getFilePath();

        if (status == 1) {

            // 校验并保存数据
            AjaxResult ajaxResult = saveSysSlumpPerformanceV2(excelPath);
            if (ajaxResult.isError()) {
                return ajaxResult;
            }

            // 更新审核状态为通过
            boolean success = sysExcelAuditService.update(
                    new LambdaUpdateWrapper<SysExcelAudit>()
                            .eq(SysExcelAudit::getId, id)
                            .set(SysExcelAudit::getStatus, 1)
                            .set(SysExcelAudit::getUpdateTime, LocalDateTime.now())
                            .set(SysExcelAudit::getReason, reason)
            );

            return success
                    ? AjaxResult.success("审核通过，" + ajaxResult.get("msg"))
                    : AjaxResult.error("审核通过失败，数据库更新失败");

        } else if (status == 2) {
            // 审核未通过
            boolean success = sysExcelAuditService.update(
                    new LambdaUpdateWrapper<SysExcelAudit>()
                            .eq(SysExcelAudit::getId, id)
                            .set(SysExcelAudit::getStatus, 2)
                            .set(SysExcelAudit::getUpdateTime, LocalDateTime.now())
                            .set(SysExcelAudit::getReason, reason)
            );

            return success
                    ? AjaxResult.success("审核未通过")
                    : AjaxResult.error("状态更新失败");
        }

        // 如果 status 不是 1 或 2
        return AjaxResult.error("非法的审核状态码");
    }


    /**
     * 14 插入坍落度
     *
     * @param filePath
     * @param id
     * @param status
     * @return
     */
    @Transactional
    public AjaxResult saveSysSlumpPerformanceV2(String filePath) {
        ObjectMapper objectMapper = new ObjectMapper();
        List<List<String>> data;
        try {
            // 检查文件是否存在
            File jsonFile = new File(filePath);
            if (!jsonFile.exists()) {
                return AjaxResult.error("文件不存在: " + filePath);
            }

            // 解析 JSON 文件为二维数组（每一行是一条水泥记录）
            data = objectMapper.readValue(jsonFile, new com.fasterxml.jackson.core.type.TypeReference<List<List<String>>>() {
            });
        } catch (IOException e) {
            e.printStackTrace();
            return AjaxResult.error("JSON 文件解析失败: " + e.getMessage());
        }


        int successfulInserts = 0;


        // 获取水泥数据并存储在一个集合中
        LambdaQueryWrapper<SysCement> wrapper = new LambdaQueryWrapper<>();
        List<SysCement> list = sysCementService.list(wrapper);
        Map<String, SysCement> sysCementMap = new HashMap<>();

        for (SysCement sysCement : list) {
            String key = sysCement.getModel() + "-" + sysCement.getRegionName() + "-" + sysCement.getStrengthGrade() +
                    "-" + sysCement.getCaoContent() + "-" + sysCement.getSio2Content() + "-" + sysCement.getAl2o3Content() + "-" + sysCement.getCompressiveStrength28d();
            sysCementMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石头记录并存储在一个集合中
        LambdaQueryWrapper<SysStone> wrapperStone = new LambdaQueryWrapper<>();
        List<SysStone> listStone = sysStoneService.list(wrapperStone);
        Map<String, SysStone> sysStonMap = new HashMap<>();
        System.out.println("sysCementMap" + sysStonMap);
        for (SysStone sysCement : listStone) {
            String keyStone = sysCement.getModel() + "-" + sysCement.getStoneSpecification() +
                    "-" + sysCement.getStackingDensity() + "-" + sysCement.getCompactDensity() +
                    "-" + sysCement.getBulkDensity() + "-" + sysCement.getRegionName();

            sysStonMap.put(keyStone, sysCement);
        }


        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysFlyash> wrapperFlyash = new LambdaQueryWrapper<>();
        List<SysFlyash> listFlyash = sysFlyashService.list(wrapperFlyash);
        Map<String, SysFlyash> flyashMap = new HashMap<>();

        for (SysFlyash sysCement : listFlyash) {
            String keyFlyash = sysCement.getGrade() + "-" + sysCement.getFactoryGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            flyashMap.put(keyFlyash, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的砂记录并存储在一个集合中
        LambdaQueryWrapper<SysSand> wrapperSand = new LambdaQueryWrapper<>();
        List<SysSand> listSand = sysSandService.list(wrapperSand);
        // 使用一个唯一的组合键作为 Map 的 key
        Map<String, SysSand> sysSandMap = new HashMap<>();
        for (SysSand sysCement : listSand) {
            String key = sysCement.getType() + "-" + sysCement.getFineness() + "-" + sysCement.getBulkDensity() + "-"
                    + sysCement.getCompactDensity() + "-" + sysCement.getApparentDensity() + "-" + sysCement.getParticleSizeDistribution()
                    + "-" + sysCement.getRegionName();
            sysSandMap.put(key, sysCement);  // 使用唯一的组合键作为 map 的 key
        }


        // 获取所有已存在的石粉记录并存储在一个集合中
        LambdaQueryWrapper<SysOtherAdmixtures> wrapperOtherAdmixtures = new LambdaQueryWrapper<>();
        List<SysOtherAdmixtures> listOtherAdmixtures = sysOtherAdmixturesService.list(wrapperOtherAdmixtures);
        Map<String, SysOtherAdmixtures> sysOtherAdmixturesMap = new HashMap<>();
        System.out.println("sysCementMap" + sysCementMap);
        for (SysOtherAdmixtures sysCement : listOtherAdmixtures) {
            String key = sysCement.getModel() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            sysOtherAdmixturesMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*矿粉*/
        LambdaQueryWrapper<SysMineralPowder> wrapperMineralPowder = new LambdaQueryWrapper<>();
        List<SysMineralPowder> listMineralPowder = sysMineralPowderService.list(wrapperMineralPowder);
        Map<String, SysMineralPowder> MineralPowderMap = new HashMap<>();

        for (SysMineralPowder sysCement : listMineralPowder) {
            String key = sysCement.getModel() + "-" + sysCement.getSlagGrade() + "-" + sysCement.getFineness() +
                    "-" + sysCement.getMoistureContent() + "-" + sysCement.getActivityIndex28d() + "-" + sysCement.getRegionName();
            MineralPowderMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        //减水剂
        LambdaQueryWrapper<SysWaterReducer> wrapperWaterReducer = new LambdaQueryWrapper<>();
        List<SysWaterReducer> listWaterReducer = sysWaterReducerService.list(wrapperWaterReducer);
        Map<String, SysWaterReducer> sysWaterReducerMap = new HashMap<>();
        System.out.println("list" + list);
        for (SysWaterReducer sysCement : listWaterReducer) {
            String keyWaterReducer = sysCement.getModel() + "-" + sysCement.getSolidContent() + "-" + sysCement.getCementPasteFlow() + "-" + sysCement.getReducingRate() + "-" + sysCement.getSourceName();

            sysWaterReducerMap.put(keyWaterReducer, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }

        System.out.println("减水剂数据库字段" + sysWaterReducerMap);

        /*增效剂*/
        LambdaQueryWrapper<SysEfficiencyAgent> wrapperEfficiencyAgent = new LambdaQueryWrapper<>();
        List<SysEfficiencyAgent> listEfficiencyAgent = sysEfficiencyAgentService.list(wrapperEfficiencyAgent);
        Map<String, SysEfficiencyAgent> efficiencyAgentMap = new HashMap<>();
        System.out.println("list" + listEfficiencyAgent);
        for (SysEfficiencyAgent sysCement : listEfficiencyAgent) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            efficiencyAgentMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        /*膨胀剂*/
        // 获取所有已存在的水泥记录并存储在一个集合中
        LambdaQueryWrapper<SysSwellingagent> wrapperSwellingagent = new LambdaQueryWrapper<>();
        List<SysSwellingagent> listSysSwelling = sysSwellingagentService.list(wrapperSwellingagent);
        Map<String, SysSwellingagent> SysSwellingMap = new HashMap<>();
        System.out.println("list" + listSysSwelling);
        for (SysSwellingagent sysCement : listSysSwelling) {
            String key = sysCement.getModel() + "-" + sysCement.getSourceName();
            SysSwellingMap.put(key, sysCement);  // 使用一个唯一的组合键作为 map 的 key
        }


        // 创建一个临时列表，用于存储要插入的数据
        //  List<SysMechanicalPerformance> batchInsertList = new ArrayList<>();
        List<SysSlump> batchInsertList = new ArrayList<>();

        // 遍历每条水泥数据
        for (List<String> record : data) {
//            if (record.size() != 15) {
//                System.err.println("无效数据格式: " + record);
//                continue;
//            }


            // 解析数据
            //String regiona = record.get(0);  // 地区
            int regiona = Integer.parseInt(record.get(0));//来源地区

            // String productionDate = record.get(1);  // //生产日期
            String productionDateStr = record.get(1);
            LocalDateTime productionDate = LocalDate.parse(productionDateStr, DateTimeFormatter.ofPattern("yyyy-MM-dd"))
                    .atStartOfDay();


            //String slump = record.get(2);
            BigDecimal slump = new BigDecimal(record.get(2));
            slump = slump.setScale(2, RoundingMode.HALF_UP);

            ;//强度等级
//            BigDecimal compressive3d = new BigDecimal(record.get(3));
//            ;//3天抗压强度(MPa)
//            BigDecimal compressive7d = new BigDecimal(record.get(4));  //7天抗压强度(MPa)
//            BigDecimal compressive28d = new BigDecimal(record.get(5));  //28天抗压强度(MPa)
            BigDecimal water = new BigDecimal(record.get(6));   //水掺量(kg/m³)

            BigDecimal cement = new BigDecimal(record.get(7));
            ;////水泥掺量(kg/m³)

            water = water.setScale(2, RoundingMode.HALF_UP);
            cement = cement.setScale(2, RoundingMode.HALF_UP);







            /*水泥*/
            // 解析数据
            String model = record.get(8);
            BigDecimal cao = new BigDecimal(record.get(9));
            BigDecimal sio2 = new BigDecimal(record.get(10));
            BigDecimal al2o3 = new BigDecimal(record.get(11));
            BigDecimal compressive = new BigDecimal(record.get(12));
            BigDecimal strength = new BigDecimal(record.get(13));
            int region = Integer.parseInt(record.get(14));

            // 确保所有 BigDecimal 保留两位小数
            cao = cao.setScale(2, RoundingMode.HALF_UP);
            sio2 = sio2.setScale(2, RoundingMode.HALF_UP);
            al2o3 = al2o3.setScale(2, RoundingMode.HALF_UP);
            compressive = compressive.setScale(2, RoundingMode.HALF_UP);
            strength = strength.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String key = model + "-" + region + "-" + strength + "-" + cao + "-" + sio2 + "-" + al2o3 + "-" + compressive;

            Integer cementId;

            if (sysCementMap.containsKey(key)) {
                // 记录存在，直接拿id
//                cementId = sysCementMap.get(key).getId();
                cementId = sysCementMap.get(key).getCementId();  // 使用正确的字段名称
                System.out.println("找到已有水泥数据，id = " + cementId);
            } else {
                // 记录不存在，创建新的SysCement
                SysCement newCement = new SysCement();
                newCement.setId(IdUtils.generateRandomNumber());  // 生成id
                newCement.setModel(model);
                newCement.setRegionName(region); // 注意，regionName是字符串！
                newCement.setStrengthGrade(strength);
                newCement.setCaoContent(cao);
                newCement.setSio2Content(sio2);
                newCement.setAl2o3Content(al2o3);
                newCement.setCompressiveStrength28d(compressive);
                newCement.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));

                sysCementService.save(newCement);
                sysCementMap.put(key, newCement); // 插入map缓存
                cementId = newCement.getId();
                System.out.println("新增水泥数据，id = " + cementId);
            }
//            // 替换第8列（索引8）为水泥id
//            record.set(8, String.valueOf(cementId));
//          // 删除索引9到14的元素（一定要从大到小删）
//            for (int i = 14; i >= 9; i--) {
//                record.remove(i);
//            }


            /*-------------------------------------------------------------------------------------*/
            // String stone510 = record.get(15);// 石头5-10掺量
            BigDecimal stone510 = new BigDecimal(record.get(15));// 石头5-10掺量
            stone510 = stone510.setScale(2, RoundingMode.HALF_UP);

            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone510 = record.get(16); // 型号
            String stoneSpecification510 = record.get(17); // 石子规格
            BigDecimal stackingDensity510 = new BigDecimal(record.get(18)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity510 = new BigDecimal(record.get(19)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity510 = new BigDecimal(record.get(20)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName = record.get(21); // 来源地区

            Integer regionName510 = Integer.parseInt(regionName);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone510 = modelstone510 + "-" + stoneSpecification510 + "-" + stackingDensity510 + "-" + compactDensity510 + "-" + bulkDensity510 + "-" + regionName510;
            System.out.println("key: " + key);

            Integer stone510Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone510)) {
                stone510Id = sysStonMap.get(keyModelStone510).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在水泥数据stone510Id" + stone510Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone510);
                sysStone.setStoneSpecification(stoneSpecification510);
                sysStone.setStackingDensity(stackingDensity510);
                sysStone.setCompactDensity(compactDensity510);
                sysStone.setBulkDensity(bulkDensity510);
                sysStone.setRegionName(regionName510);
                sysStone.setId(IdUtils.generateRandomNumber());

                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone510, sysStone);
                stone510Id = sysStone.getStoneId();
                System.out.println("新增石头数据，id = " + stone510Id);
            }


            /*石头石5-25mm----------------------------*/


            //String stone525 = record.get(22);// 石头5-10掺量
            BigDecimal stone525 = new BigDecimal(record.get(22));// 石头5-10掺量
            stone525 = stone525.setScale(2, RoundingMode.HALF_UP);




            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone525 = record.get(23); // 型号
            String stoneSpecification525 = record.get(24); // 石子规格
            BigDecimal stackingDensity525 = new BigDecimal(record.get(25)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity525 = new BigDecimal(record.get(26)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity525 = new BigDecimal(record.get(27)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName525 = record.get(28); // 来源地区
            Integer regionName525s = Integer.parseInt(regionName525);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone525 = modelstone525 + "-" + stoneSpecification525 + "-" + stackingDensity525 + "-" + compactDensity525 + "-" + bulkDensity525 + "-" + regionName525s;
            System.out.println("key: " + key);

            Integer stone525Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone525)) {
                stone525Id = sysStonMap.get(keyModelStone525).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone510Id" + stone525Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone525);
                sysStone.setStoneSpecification(stoneSpecification525);
                sysStone.setStackingDensity(stackingDensity525);
                sysStone.setCompactDensity(compactDensity525);
                sysStone.setBulkDensity(bulkDensity525);
                sysStone.setRegionName(regionName525s);
                sysStone.setId(IdUtils.generateRandomNumber());

                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone525, sysStone);
                stone525Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone525，id = " + stone525Id);
            }

            /*石头石20-40mm----------------------------*/

            // String stone2040 = record.get(29);// 石头20-40掺量

            BigDecimal stone2040 = new BigDecimal(record.get(29));// 石头20-40掺量
            stone2040 = stone2040.setScale(2, RoundingMode.HALF_UP);



            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone2040 = record.get(30); // 型号
            String stoneSpecification2040 = record.get(31); // 石子规格
            BigDecimal stackingDensity2040 = new BigDecimal(record.get(32)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity2040 = new BigDecimal(record.get(33)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity2040 = new BigDecimal(record.get(34)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName2040 = record.get(35); // 来源地区
            Integer regionName2040s = Integer.parseInt(regionName2040);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone2040 = modelstone2040 + "-" + stoneSpecification2040 + "-" + stackingDensity2040 + "-" + compactDensity2040 + "-" + bulkDensity2040 + "-" + regionName2040s;
            System.out.println("key: " + keyModelStone2040);

            Integer stone2040Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone2040)) {
                stone2040Id = sysStonMap.get(keyModelStone2040).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone2040Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone2040);
                sysStone.setStoneSpecification(stoneSpecification2040);
                sysStone.setStackingDensity(stackingDensity2040);
                sysStone.setCompactDensity(compactDensity2040);
                sysStone.setBulkDensity(bulkDensity2040);
                sysStone.setRegionName(regionName2040s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone2040Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone525，id = " + stone2040Id);
            }


            /*石头20-20*/

            //  String stone1020 = record.get(36);// 石头10-50掺量

            BigDecimal stone1020 = new BigDecimal(record.get(36));// 石头5-10掺量
            stone1020 = stone1020.setScale(2, RoundingMode.HALF_UP);


            /*石头5-10*/
            // 解析数据并保证两位小数
            String modelstone1020 = record.get(37); // 型号
            String stoneSpecification1020 = record.get(38); // 石子规格
            BigDecimal stackingDensity1020 = new BigDecimal(record.get(39)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1020 = new BigDecimal(record.get(40)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1020 = new BigDecimal(record.get(41)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1020 = record.get(42); // 来源地区
            Integer regionName1020s = Integer.parseInt(regionName1020);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1020 = modelstone1020 + "-" + stoneSpecification1020 + "-" + stackingDensity1020 + "-" + compactDensity1020 + "-" + bulkDensity1020 + "-" + regionName1020s;
            System.out.println("key: " + keyModelStone1020);

            Integer stone1020Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1020)) {
                stone1020Id = sysStonMap.get(keyModelStone1020).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone1020Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1020);
                sysStone.setStoneSpecification(stoneSpecification1020);
                sysStone.setStackingDensity(stackingDensity1020);
                sysStone.setCompactDensity(compactDensity1020);
                sysStone.setBulkDensity(bulkDensity1020);
                sysStone.setRegionName(regionName1020s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone2040, sysStone);
                stone1020Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone1020，id = " + stone1020Id);
            }

            /*石头10-30*/

            // String stone1030 = record.get(43);// 石头10-30掺量

            BigDecimal stone1030 = new BigDecimal(record.get(43));// 石头10-30掺量
            stone1030 = stone1030.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone1030 = record.get(44); // 型号
            String stoneSpecification1030 = record.get(45); // 石子规格
            BigDecimal stackingDensity1030 = new BigDecimal(record.get(46)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity1030 = new BigDecimal(record.get(47)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity1030 = new BigDecimal(record.get(48)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName1030 = record.get(49); // 来源地区
            Integer regionName1030s = Integer.parseInt(regionName1030);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone1030 = modelstone1030 + "-" + stoneSpecification1030 + "-" + stackingDensity1030 + "-" + compactDensity1030 + "-" + bulkDensity1030 + "-" + regionName1030s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone1030Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone1030)) {
                stone1030Id = sysStonMap.get(keyModelStone1030).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone2040Id" + stone1030Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone1030);
                sysStone.setStoneSpecification(stoneSpecification1030);
                sysStone.setStackingDensity(stackingDensity1030);
                sysStone.setCompactDensity(compactDensity1030);
                sysStone.setBulkDensity(bulkDensity1030);
                sysStone.setRegionName(regionName1030s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone1030, sysStone);
                stone1030Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone1020，id = " + stone1030Id);
            }

            /*石头0-10*/

            //String stone010 = record.get(50);// 石头0-10掺量

            BigDecimal stone010 = new BigDecimal(record.get(50));//石头0-10掺
            stone010 = stone010.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone010 = record.get(51); // 型号
            String stoneSpecification010 = record.get(52); // 石子规格
            BigDecimal stackingDensity010 = new BigDecimal(record.get(53)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity010 = new BigDecimal(record.get(54)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity010 = new BigDecimal(record.get(55)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName010 = record.get(56); // 来源地区
            Integer regionName010s = Integer.parseInt(regionName010);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone010 = modelstone010 + "-" + stoneSpecification010 + "-" + stackingDensity010 + "-" + compactDensity010 + "-" + bulkDensity010 + "-" + regionName010s;
            System.out.println("key: " + keyModelStone1030);

            Integer stone010Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone010)) {
                stone010Id = sysStonMap.get(keyModelStone010).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone010Id" + stone010Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone010);
                sysStone.setStoneSpecification(stoneSpecification010);
                sysStone.setStackingDensity(stackingDensity010);
                sysStone.setCompactDensity(compactDensity010);
                sysStone.setBulkDensity(bulkDensity010);
                sysStone.setRegionName(regionName010s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone010, sysStone);
                stone010Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone010，id = " + stone010Id);
            }




            /*石头20-315*/

            //  String stone20315 = record.get(57);// 石头20-315掺量

            BigDecimal stone20315 = new BigDecimal(record.get(57));// 石头5-10掺量
            stone20315 = stone20315.setScale(2, RoundingMode.HALF_UP);


            // 解析数据并保证两位小数
            String modelstone20315 = record.get(58); // 型号
            String stoneSpecification20315 = record.get(59); // 石子规格
            BigDecimal stackingDensity20315 = new BigDecimal(record.get(60)).setScale(2, RoundingMode.HALF_UP); // 堆积密度
            BigDecimal compactDensity20315 = new BigDecimal(record.get(61)).setScale(2, RoundingMode.HALF_UP); // 紧密密度
            BigDecimal bulkDensity20315 = new BigDecimal(record.get(62)).setScale(2, RoundingMode.HALF_UP); // 表观密度
            String regionName20315 = record.get(63); // 来源地区
            Integer regionName20315s = Integer.parseInt(regionName20315);

            // 构造一个唯一的键（直接拼接）
            String keyModelStone20315 = modelstone20315 + "-" + stoneSpecification20315 + "-" + stackingDensity20315 + "-" + compactDensity20315 + "-" + bulkDensity20315 + "-" + regionName20315s;
            System.out.println("key: " + keyModelStone20315);

            Integer stone20315Id;
            // 判断是否存在该记录
            if (sysStonMap.containsKey(keyModelStone20315)) {
                stone20315Id = sysStonMap.get(keyModelStone20315).getStoneId();  // 使用正确的字段名称
                System.out.println("数据库已经存在石头数据stone20315Id" + stone20315Id);
            } else {
                // 创建 SysStone 对象并加入临时列表
                SysStone sysStone = new SysStone();
                sysStone.setModel(modelstone20315);
                sysStone.setStoneSpecification(stoneSpecification20315);
                sysStone.setStackingDensity(stackingDensity20315);
                sysStone.setCompactDensity(compactDensity20315);
                sysStone.setBulkDensity(bulkDensity20315);
                sysStone.setRegionName(regionName20315s);
                sysStone.setId(IdUtils.generateRandomNumber());
                sysStoneService.save(sysStone);
                sysStonMap.put(keyModelStone20315, sysStone);
                stone20315Id = sysStone.getStoneId();
                System.out.println("新增石头数据stone010，id = " + stone20315Id);
            }

            /*河沙粗 31-37*/
            // String sand3137 = record.get(64);//砂3137参量

            BigDecimal sand3137 = new BigDecimal(record.get(64));// 石头5-10掺量
            sand3137 = sand3137.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137 = record.get(65);  // 砂3137型号
            BigDecimal sandFineness3137 = new BigDecimal(record.get(66));  // 砂3137细度
            BigDecimal sandBulkDensity3137 = new BigDecimal(record.get(67));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137 = new BigDecimal(record.get(68));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137 = new BigDecimal(record.get(69));  // 砂3137表观密度 (kg/m3)

            String sandParticleSizeDistribution = record.get(70);  //砂3137 粒径分布(mm)
            int regionSand3137 = Integer.parseInt(record.get(71));

            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137 = sandFineness3137.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137 = sandBulkDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137 = sandCompactDensity3137.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137 = sandApparentDensity3137.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137 = sandModel3137 + "-" + sandFineness3137 + "-" + sandBulkDensity3137 + "-" + sandCompactDensity3137 + "-" + sandApparentDensity3137 + "-"
                    + sandParticleSizeDistribution + "-" + regionSand3137;
            System.out.println("key: " + keySand3137);


            Integer sand3137Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137)) {
                sand3137Id = sysSandMap.get(keySand3137).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand3137Id" + sand3137Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137);
                sysSand.setFineness(sandFineness3137);
                sysSand.setBulkDensity(sandBulkDensity3137);
                sysSand.setCompactDensity(sandCompactDensity3137);
                sysSand.setApparentDensity(sandApparentDensity3137);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution);
                sysSand.setRegionName(regionSand3137);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand3137, sysSand);
                sand3137Id = sysSand.getSandId();

                System.out.println("新增砂头数据sandId3137，id = " + sand3137Id);
            }

            /*河沙粗 23-30*/

            // String sand2330 = record.get(72);//砂3137参量
            BigDecimal sand2330 = new BigDecimal(record.get(72));// 石头5-10掺量
            sand2330 = sand2330.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330 = record.get(73);  // 砂3137型号
            BigDecimal sandFineness2330 = new BigDecimal(record.get(74));  // 砂3137细度
            BigDecimal sandBulkDensity2330 = new BigDecimal(record.get(75));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330 = new BigDecimal(record.get(76));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330 = new BigDecimal(record.get(77));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330 = record.get(78);  //砂3137 粒径分布(mm)
            int regionSand2330 = Integer.parseInt(record.get(79));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330 = sandFineness2330.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330 = sandBulkDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330 = sandCompactDensity2330.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330 = sandApparentDensity2330.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330 = sandModel2330 + "-" + sandFineness2330 + "-" + sandBulkDensity2330 + "-" + sandCompactDensity2330 + "-" + sandApparentDensity2330 + "-"
                    + sandParticleSizeDistribution2330 + "-" + regionSand2330;
            System.out.println("key: " + keySand2330);


            Integer sand2330Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330)) {
                sand2330Id = sysSandMap.get(keySand2330).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand2330Id" + sand2330Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330);
                sysSand.setFineness(sandFineness2330);
                sysSand.setBulkDensity(sandBulkDensity2330);
                sysSand.setCompactDensity(sandCompactDensity2330);
                sysSand.setApparentDensity(sandApparentDensity2330);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand2330, sysSand);
                sand2330Id = sysSand.getSandId();

                System.out.println("新增砂头数据sand2330Id，id = " + sand2330Id);
            }

            /*河砂细16-22mm*/

            // String sand1622 = record.get(80);//砂316 22参量

            BigDecimal sand1622 = new BigDecimal(record.get(80));// 石头5-10掺量
            sand1622 = sand1622.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622 = record.get(81);  // 砂3137型号
            BigDecimal sandFineness1622 = new BigDecimal(record.get(82));  // 砂3137细度
            BigDecimal sandBulkDensity1622 = new BigDecimal(record.get(83));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622 = new BigDecimal(record.get(84));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622 = new BigDecimal(record.get(85));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622 = record.get(86);  //砂3137 粒径分布(mm)
            int regionSand1622 = Integer.parseInt(record.get(87));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622 = sandFineness1622.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622 = sandBulkDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622 = sandCompactDensity1622.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622 = sandApparentDensity1622.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622 = sandModel1622 + "-" + sandFineness1622 + "-" + sandBulkDensity1622 + "-" + sandCompactDensity1622 + "-" + sandApparentDensity1622 + "-"
                    + sandParticleSizeDistribution1622 + "-" + regionSand1622;
            System.out.println("key: " + keySand1622);


            Integer sand1622Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622)) {
                sand1622Id = sysSandMap.get(keySand1622).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand1622Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622);
                sysSand.setFineness(sandFineness1622);
                sysSand.setBulkDensity(sandBulkDensity1622);
                sysSand.setCompactDensity(sandCompactDensity1622);
                sysSand.setApparentDensity(sandApparentDensity1622);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622);
                sysSand.setRegionName(regionSand2330);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand1622, sysSand);
                sand1622Id = sysSand.getSandId();

                System.out.println("新增砂头数据sand1622Id，id = " + sand1622Id);
            }
            /*机制砂中23-30Bmm*/
            //  String sand2330B = record.get(88);//砂3137参量
            BigDecimal sand2330B = new BigDecimal(record.get(88));// 机制砂中23-30B
            sand2330B = sand2330B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel2330B = record.get(89);  // 砂3137型号
            BigDecimal sandFineness2330B = new BigDecimal(record.get(90));  // 砂3137细度
            BigDecimal sandBulkDensity2330B = new BigDecimal(record.get(91));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity2330B = new BigDecimal(record.get(92));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity2330B = new BigDecimal(record.get(93));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution2330B = record.get(94);  //砂3137 粒径分布(mm)
            int regionSand2330B = Integer.parseInt(record.get(95));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness2330B = sandFineness2330B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity2330B = sandBulkDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity2330B = sandCompactDensity2330B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity2330B = sandApparentDensity2330B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand2330B = sandModel2330B + "-" + sandFineness2330B + "-" + sandBulkDensity2330B + "-" + sandCompactDensity2330B + "-" + sandApparentDensity2330B + "-"
                    + sandParticleSizeDistribution2330B + "-" + regionSand2330B;
            System.out.println("key: " + keySand2330B);


            Integer sand2330BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand2330B)) {
                sand2330BId = sysSandMap.get(keySand2330B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand2330BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel2330B);
                sysSand.setFineness(sandFineness2330B);
                sysSand.setBulkDensity(sandBulkDensity2330B);
                sysSand.setCompactDensity(sandCompactDensity2330B);
                sysSand.setApparentDensity(sandApparentDensity2330B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution2330B);
                sysSand.setRegionName(regionSand2330B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand2330B, sysSand);
                sand2330BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand2330BId);
            }


            /*机制粗中31-37Bmm*/
            // String sand3137B = record.get(96);//砂3137参量

            BigDecimal sand3137B = new BigDecimal(record.get(96));// 石头5-10掺量
            sand3137B = sand3137B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel3137B = record.get(97);  // 砂3137型号
            BigDecimal sandFineness3137B = new BigDecimal(record.get(98));  // 砂3137细度
            BigDecimal sandBulkDensity3137B = new BigDecimal(record.get(99));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity3137B = new BigDecimal(record.get(100));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity3137B = new BigDecimal(record.get(101));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution3137B = record.get(102);  //砂3137 粒径分布(mm)
            int regionSand3137B = Integer.parseInt(record.get(103));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness3137B = sandFineness3137B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity3137B = sandBulkDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity3137B = sandCompactDensity3137B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity3137B = sandApparentDensity3137B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand3137B = sandModel3137B + "-" + sandFineness3137B + "-" + sandBulkDensity3137B + "-" + sandCompactDensity3137B + "-" + sandApparentDensity3137B + "-"
                    + sandParticleSizeDistribution3137B + "-" + regionSand3137B;
            System.out.println("key: " + keySand2330B);


            Integer sand3137BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand3137B)) {
                sand3137BId = sysSandMap.get(keySand3137B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand3137BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel3137B);
                sysSand.setFineness(sandFineness3137B);
                sysSand.setBulkDensity(sandBulkDensity3137B);
                sysSand.setCompactDensity(sandCompactDensity3137B);
                sysSand.setApparentDensity(sandApparentDensity3137B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution3137B);
                sysSand.setRegionName(regionSand3137B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand3137B, sysSand);
                sand3137BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand3137BId);
            }

            /*机制砂细16-22Bmm*/
            // String sand1622B = record.get(104);//砂3137参量

            BigDecimal sand1622B = new BigDecimal(record.get(104));// 石头5-10掺量
            sand1622B = sand1622B.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel1622B = record.get(105);  // 砂3137型号
            BigDecimal sandFineness1622B = new BigDecimal(record.get(106));  // 砂3137细度
            BigDecimal sandBulkDensity1622B = new BigDecimal(record.get(107));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity1622B = new BigDecimal(record.get(108));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity1622B = new BigDecimal(record.get(109));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution1622B = record.get(110);  //砂3137 粒径分布(mm)
            int regionSand1622B = Integer.parseInt(record.get(111));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness1622B = sandFineness1622B.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity1622B = sandBulkDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity1622B = sandCompactDensity1622B.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity1622B = sandApparentDensity1622B.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand1622B = sandModel1622B + "-" + sandFineness1622B + "-" + sandBulkDensity1622B + "-" + sandCompactDensity1622B + "-" + sandApparentDensity1622B + "-"
                    + sandParticleSizeDistribution1622B + "-" + regionSand1622B;
            System.out.println("key: " + keySand2330B);


            Integer sand1622BId;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand1622B)) {
                sand1622BId = sysSandMap.get(keySand1622B).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand1622BId);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel1622B);
                sysSand.setFineness(sandFineness1622B);
                sysSand.setBulkDensity(sandBulkDensity1622B);
                sysSand.setCompactDensity(sandCompactDensity1622B);
                sysSand.setApparentDensity(sandApparentDensity1622B);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution1622B);
                sysSand.setRegionName(regionSand1622B);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand1622B, sysSand);
                sand1622BId = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand1622BId);
            }


            /*砂0475*/
            // String sand0475 = record.get(112);//砂3137参量

            BigDecimal sand0475 = new BigDecimal(record.get(112));// 石头5-10掺量
            sand0475 = sand0475.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel0475 = record.get(113);  // 砂3137型号
            BigDecimal sandFineness0475 = new BigDecimal(record.get(114));  // 砂3137细度
            BigDecimal sandBulkDensity0475 = new BigDecimal(record.get(115));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity0475 = new BigDecimal(record.get(116));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity0475 = new BigDecimal(record.get(117));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution0475 = record.get(118);  //砂3137 粒径分布(mm)
            int regionSand0475 = Integer.parseInt(record.get(119));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness0475 = sandFineness0475.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity0475 = sandBulkDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity0475 = sandCompactDensity0475.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity0475 = sandApparentDensity0475.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand0475 = sandModel0475 + "-" + sandFineness0475 + "-" + sandBulkDensity0475 + "-" + sandCompactDensity0475 + "-" + sandApparentDensity0475 + "-"
                    + sandParticleSizeDistribution0475 + "-" + regionSand0475;
            System.out.println("key: " + keySand2330B);


            Integer sand0475Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand0475)) {
                sand0475Id = sysSandMap.get(keySand0475).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand0475Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel0475);
                sysSand.setFineness(sandFineness0475);
                sysSand.setBulkDensity(sandBulkDensity0475);
                sysSand.setCompactDensity(sandCompactDensity0475);
                sysSand.setApparentDensity(sandApparentDensity0475);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution0475);
                sysSand.setRegionName(regionSand0475);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand0475, sysSand);
                sand0475Id = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand0475Id);
            }

            /*砂09*/
            //String sand09 = record.get(120);//砂3137参量

            BigDecimal sand09 = new BigDecimal(record.get(120));// 石头5-10掺量
            sand09 = sand09.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String sandModel09 = record.get(121);  // 砂3137型号
            BigDecimal sandFineness09 = new BigDecimal(record.get(122));  // 砂3137细度
            BigDecimal sandBulkDensity09 = new BigDecimal(record.get(123));  // 砂3137堆积密度 (kg/m3)
            BigDecimal sandCompactDensity09 = new BigDecimal(record.get(124));  // 砂3137紧密密度 (kg/m3)
            BigDecimal sandApparentDensity09 = new BigDecimal(record.get(125));  // 砂3137表观密度 (kg/m3)
            String sandParticleSizeDistribution09 = record.get(126);  //砂3137 粒径分布(mm)
            int regionSand09 = Integer.parseInt(record.get(127));
            // 确保所有 BigDecimal 保留两位小数
            sandFineness09 = sandFineness09.setScale(2, RoundingMode.HALF_UP);
            sandBulkDensity09 = sandBulkDensity09.setScale(2, RoundingMode.HALF_UP);
            sandCompactDensity09 = sandCompactDensity09.setScale(2, RoundingMode.HALF_UP);
            sandApparentDensity09 = sandApparentDensity09.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键（唯一标识记录的组合字段）
            String keySand09 = sandModel09 + "-" + sandFineness09 + "-" + sandBulkDensity09 + "-" + sandCompactDensity09 + "-" + sandApparentDensity09 + "-"
                    + sandParticleSizeDistribution09 + "-" + regionSand09;
            System.out.println("key: " + keySand09);


            Integer sand09Id;
            // 判断是否存在该记录
            if (sysSandMap.containsKey(keySand09)) {
                sand09Id = sysSandMap.get(keySand09).getSandId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据sand1622Id" + sand09Id);

            } else {
                // 创建 SysSand 对象并加入临时列表
                SysSand sysSand = new SysSand();
                sysSand.setType(sandModel09);
                sysSand.setFineness(sandFineness09);
                sysSand.setBulkDensity(sandBulkDensity09);
                sysSand.setCompactDensity(sandCompactDensity09);
                sysSand.setApparentDensity(sandApparentDensity09);
                sysSand.setParticleSizeDistribution(sandParticleSizeDistribution09);
                sysSand.setRegionName(regionSand09);
                sysSand.setId(IdUtils.generateRandomNumber());

                sysSandService.save(sysSand);
                sysSandMap.put(keySand09, sysSand);
                sand09Id = sysSand.getSandId();
                System.out.println("新增砂头数据sand1622Id，id = " + sand09Id);
            }

            /* 石粉*/

            // String otherAdmixturesStonePowder = record.get(128);//石粉用量
            BigDecimal otherAdmixturesStonePowder = new BigDecimal(record.get(128));// 石头5-10掺量
            otherAdmixturesStonePowder = otherAdmixturesStonePowder.setScale(2, RoundingMode.HALF_UP);


            // 解析数据
            String otherAdmixturesModel = record.get(129);//型号

            BigDecimal otherAdmixturesFineness = new BigDecimal(record.get(130));//细度
            BigDecimal otherAdmixturesMoistureContent = new BigDecimal(record.get(131));//含水量
            BigDecimal otherAdmixturesActivityIndex28d = new BigDecimal(record.get(132));//28天活性指数(%)

            int otherAdmixturesRegionName = Integer.parseInt(record.get(133));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            otherAdmixturesFineness = otherAdmixturesFineness.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesMoistureContent = otherAdmixturesMoistureContent.setScale(2, RoundingMode.HALF_UP);
            otherAdmixturesActivityIndex28d = otherAdmixturesActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            // 构造一个唯一的键
            String otherAdmixturesKey = otherAdmixturesModel + "-" + otherAdmixturesFineness + "-" + otherAdmixturesMoistureContent + "-" + otherAdmixturesActivityIndex28d + "-" + otherAdmixturesRegionName;
            System.out.println("key" + otherAdmixturesKey);


            Integer otherAdmixturesId;
            // 判断是否存在该记录
            if (sysOtherAdmixturesMap.containsKey(otherAdmixturesKey)) {
                otherAdmixturesId = sysOtherAdmixturesMap.get(otherAdmixturesKey).getAdmixturesId();  // 使用正确的字段名称
                System.out.println("数据库已经存在砂数据otherAdmixturesId" + otherAdmixturesId);
            } else {


                SysOtherAdmixtures sysOtherAdmixtures = new SysOtherAdmixtures();
                sysOtherAdmixtures.setModel(otherAdmixturesModel);
                sysOtherAdmixtures.setFineness(otherAdmixturesFineness);
                sysOtherAdmixtures.setMoistureContent(otherAdmixturesMoistureContent);
                sysOtherAdmixtures.setActivityIndex28d(otherAdmixturesActivityIndex28d);
                sysOtherAdmixtures.setRegionName(otherAdmixturesRegionName);
                sysOtherAdmixtures.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysOtherAdmixtures.setId(IdUtils.generateRandomNumber());

                sysOtherAdmixturesService.save(sysOtherAdmixtures);
                sysOtherAdmixturesMap.put(otherAdmixturesKey, sysOtherAdmixtures);

                otherAdmixturesId = sysOtherAdmixtures.getAdmixturesId();
                System.out.println("新增砂头数据otherAdmixturesId，id = " + otherAdmixturesId);
            }

            /*矿粉*/
            //  String mineralPowder = record.get(134);//矿粉掺量
            BigDecimal mineralPowder = new BigDecimal(record.get(134));// 石头5-10掺量
            mineralPowder = mineralPowder.setScale(2, RoundingMode.HALF_UP);


            String mineralPowderModel = record.get(135);//矿粉型号
            String mineralPowderSlagGrade = record.get(136);//矿粉等级

            BigDecimal mineralPowderFineness = new BigDecimal(record.get(137));//细度(%)
            BigDecimal mineralPowderMoistureContent = new BigDecimal(record.get(138));//含水量
            BigDecimal mineralPowderActivityIndex28d = new BigDecimal(record.get(139));//28天活性指数(%)
            int mineralPowderRegionName = Integer.parseInt(record.get(140));//来源地区

            // 确保所有 BigDecimal 保留两位小数
            mineralPowderFineness = mineralPowderFineness.setScale(2, RoundingMode.HALF_UP);
            mineralPowderMoistureContent = mineralPowderMoistureContent.setScale(2, RoundingMode.HALF_UP);
            mineralPowderActivityIndex28d = mineralPowderActivityIndex28d.setScale(2, RoundingMode.HALF_UP);

            String keyMineralPowder = mineralPowderModel + "-" + mineralPowderSlagGrade + "-" + mineralPowderFineness + "-" + mineralPowderMoistureContent + "-" + mineralPowderActivityIndex28d + "-" + mineralPowderRegionName;
            Integer mineralPowderId;
            // 判断是否存在该记录
            if (MineralPowderMap.containsKey(keyMineralPowder)) {
                mineralPowderId = MineralPowderMap.get(keyMineralPowder).getPowderId();  // 使用正确的字段名称
                System.out.println("数据库已经存在矿粉数据mineralPowderId" + mineralPowderId);
            } else {

                SysMineralPowder powder = new SysMineralPowder();
                powder.setModel(mineralPowderModel);
                powder.setSlagGrade(mineralPowderSlagGrade);
                powder.setFineness(mineralPowderFineness);
                powder.setMoistureContent(mineralPowderMoistureContent);
                powder.setActivityIndex28d(mineralPowderActivityIndex28d);
                powder.setRegionName(mineralPowderRegionName);
                powder.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                powder.setId(IdUtils.generateRandomNumber());

                sysMineralPowderService.save(powder);
                MineralPowderMap.put(otherAdmixturesKey, powder);

                mineralPowderId = powder.getPowderId();

                System.out.println("新增矿粉数据mineralPowderId，id = " + mineralPowderId);
            }

            /*粉煤灰*/
            //String flyash = record.get(141);//粉煤灰掺量

            BigDecimal flyash = new BigDecimal(record.get(141));// 石头5-10掺量
            flyash = flyash.setScale(2, RoundingMode.HALF_UP);


            String flyashModel = record.get(142);//粉煤灰型号
            String flyashfactoryGrade = record.get(143);//粉煤灰出厂等级

            BigDecimal flyashFineness = new BigDecimal(record.get(144));//粉煤灰细度(%)
            BigDecimal flyashMoistureContent = new BigDecimal(record.get(145));//粉煤灰含水量
            BigDecimal flyashActivityIndex28d = new BigDecimal(record.get(146));//粉煤灰28天活性指数(%)
            int flyashRegionName = Integer.parseInt(record.get(147));//粉煤灰来源地区

            // 确保所有 BigDecimal 保留两位小数
            flyashFineness = flyashFineness.setScale(2, RoundingMode.HALF_UP);
            flyashMoistureContent = flyashMoistureContent.setScale(2, RoundingMode.HALF_UP);
            flyashActivityIndex28d = flyashActivityIndex28d.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyFlyash = flyashModel + "-" + flyashfactoryGrade + "-" + flyashFineness + "-" + flyashMoistureContent + "-" + flyashActivityIndex28d + "-" + flyashRegionName;


            Integer flyashId;
            // 判断是否存在该记录
            if (flyashMap.containsKey(keyFlyash)) {
                flyashId = flyashMap.get(keyFlyash).getFlyashId();
                System.out.println("数据库已经存在矿粉数据flyashId" + flyashId);
            } else {

                SysFlyash sysFlyash = new SysFlyash();
                sysFlyash.setGrade(flyashModel);
                sysFlyash.setFactoryGrade(flyashfactoryGrade);
                sysFlyash.setFineness(flyashFineness);
                sysFlyash.setMoistureContent(flyashMoistureContent);
                sysFlyash.setActivityIndex28d(flyashActivityIndex28d);
                sysFlyash.setRegionName(flyashRegionName);
                sysFlyash.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysFlyash.setId(IdUtils.generateRandomNumber());
                sysFlyashService.save(sysFlyash);

                flyashMap.put(keyFlyash, sysFlyash);
                flyashId = sysFlyash.getFlyashId();


                System.out.println("新增矿粉数据flyashId，id = " + flyashId);
            }


            /*减水剂*/

            // String waterReducer = record.get(148);//减水剂参量
            BigDecimal waterReducer = new BigDecimal(record.get(148));// 石头5-10掺量
            waterReducer = waterReducer.setScale(2, RoundingMode.HALF_UP);


            String WaterReducermodel = record.get(149);//减水剂型号

            BigDecimal WaterReducersolidContent = new BigDecimal(record.get(150));//含固量(%)
            BigDecimal WaterReducercementPasteFlow = new BigDecimal(record.get(151));//水泥净浆流动度(mm)
            BigDecimal WaterReducerreducingRate = new BigDecimal(record.get(152));//减水率

            String WaterReducerRegionName = record.get(153);//来源地区

            // 确保所有 BigDecimal 保留两位小数
            WaterReducersolidContent = WaterReducersolidContent.setScale(2, RoundingMode.HALF_UP);
            WaterReducercementPasteFlow = WaterReducercementPasteFlow.setScale(2, RoundingMode.HALF_UP);
            WaterReducerreducingRate = WaterReducerreducingRate.setScale(2, RoundingMode.HALF_UP);
            // 构造一个唯一的键
            String keyWaterReducer = WaterReducermodel + "-" + WaterReducersolidContent + "-" + WaterReducercementPasteFlow + "-" + WaterReducerreducingRate + "-" + WaterReducerRegionName;
            System.out.println("减水剂插入数据" + keyWaterReducer);
            Integer waterReducerId;
            if (sysWaterReducerMap.containsKey(keyWaterReducer)) {
                waterReducerId = sysWaterReducerMap.get(keyWaterReducer).getReducerId();
                System.out.println("减水剂 记录已存在（字段完全相同），跳过插入: " + waterReducerId);
            } else {

                SysWaterReducer sysWaterReducer = new SysWaterReducer();
                sysWaterReducer.setModel(WaterReducermodel);
                sysWaterReducer.setSolidContent(WaterReducersolidContent);
                sysWaterReducer.setCementPasteFlow(WaterReducercementPasteFlow);
                sysWaterReducer.setReducingRate(WaterReducerreducingRate);
                sysWaterReducer.setSourceName(WaterReducerRegionName);

                sysWaterReducer.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysWaterReducer.setId(IdUtils.generateRandomNumber());
                sysWaterReducerService.save(sysWaterReducer);

                sysWaterReducerMap.put(keyWaterReducer, sysWaterReducer);

                waterReducerId = sysWaterReducer.getReducerId();


                System.out.println("新增减水剂数据reducerId，id = " + waterReducerId);
            }

            /*增效剂*/
            //  String efficiencyAgent = record.get(154);//增效剂掺量

            BigDecimal efficiencyAgent = new BigDecimal(record.get(154));// 石头5-10掺量
            efficiencyAgent = efficiencyAgent.setScale(2, RoundingMode.HALF_UP);


            String efficiencyAgentModel = record.get(155);//增效剂型号
            String efficiencyAgentRegionName = record.get(156);//增效剂来源

            String efficiencyAgentKey = efficiencyAgentModel + "-" + efficiencyAgentRegionName;
            Integer efficiencyAgentId;
            if (efficiencyAgentMap.containsKey(efficiencyAgentKey)) {
                efficiencyAgentId = efficiencyAgentMap.get(efficiencyAgentKey).getAgentId();
                System.out.println("记录已存在（字段完全相同），跳过插入: " + efficiencyAgentId);
            } else {
                SysEfficiencyAgent sysEfficiencyAgent = new SysEfficiencyAgent();
                sysEfficiencyAgent.setModel(efficiencyAgentModel);
                sysEfficiencyAgent.setSourceName(efficiencyAgentRegionName);
                sysEfficiencyAgent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysEfficiencyAgent.setDeleteTime(0);
                sysEfficiencyAgent.setId(IdUtils.generateRandomNumber());

                sysEfficiencyAgentService.save(sysEfficiencyAgent);

                efficiencyAgentMap.put(efficiencyAgentKey, sysEfficiencyAgent);
                efficiencyAgentId = sysEfficiencyAgent.getAgentId();


                System.out.println("新增增效剂数据efficiencyAgentId，id = " + efficiencyAgentId);
            }


            // String swellinAagent = record.get(157);//膨胀剂掺量型号
            BigDecimal swellinAagent = new BigDecimal(record.get(157));// 石头5-10掺量
            swellinAagent = swellinAagent.setScale(2, RoundingMode.HALF_UP);


            String swellingAgentmodel = record.get(158);//型号
            String swellingAgentRegionName = record.get(159);//来源地区


            // 构造一个唯一的键
            String keySwellingagent = swellingAgentmodel + "-" + swellingAgentRegionName;
            System.out.println("哈哈哈key" + key);
            // 判断是否存在该记录

            Integer sysSwellingId;
            if (SysSwellingMap.containsKey(keySwellingagent)) {
                sysSwellingId = SysSwellingMap.get(keySwellingagent).getSwellingagentId();
                System.out.println("记录已存在（字段完全相同），跳过插入: " + sysSwellingId);
            } else {
                SysSwellingagent sysSwellingagent = new SysSwellingagent();
                sysSwellingagent.setModel(swellingAgentmodel);
                sysSwellingagent.setSourceName(swellingAgentRegionName);
                sysSwellingagent.setCreateTime(Timestamp.valueOf(LocalDateTime.now()));
                sysSwellingagent.setDeleteTime(0);
                sysSwellingagent.setId(IdUtils.generateRandomNumber());

                sysSwellingagentService.save(sysSwellingagent);
                SysSwellingMap.put(keySwellingagent, sysSwellingagent);
                sysSwellingId = sysSwellingagent.getSwellingagentId();

                System.out.println("新增膨胀剂数据sysSwellingId，id = " + sysSwellingId);
            }


            //SysMechanicalPerformance sysMechanicalPerformance = new SysMechanicalPerformance();
            SysSlump sysMechanicalPerformance = new SysSlump();
            sysMechanicalPerformance.setCementId(cementId);//1
            sysMechanicalPerformance.setStone510Id(stone510Id);//2
            sysMechanicalPerformance.setStone525Id(stone525Id);//3
            sysMechanicalPerformance.setStone2040Id(stone2040Id);//4
            sysMechanicalPerformance.setStone1020Id(stone1020Id);//5
            sysMechanicalPerformance.setStone1030Id(stone1030Id);//6
            sysMechanicalPerformance.setStone010Id(stone010Id);//7
            sysMechanicalPerformance.setStone2031Id(stone20315Id);//8
            sysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);//9
            sysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);//10
            sysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);//11
            sysMechanicalPerformance.setSandMech2330MedId(sand2330BId);//12
            sysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);//13
            sysMechanicalPerformance.setSandMech1622FineId(sand1622BId);//14
            sysMechanicalPerformance.setSandMech0475Id(sand0475Id);//15
            sysMechanicalPerformance.setSandMech09Id(sand09Id);//16
            sysMechanicalPerformance.setStonePowderId(otherAdmixturesId);//17
            sysMechanicalPerformance.setMineralPowderId(mineralPowderId);//18
            sysMechanicalPerformance.setFlyAshId(flyashId);//19
            sysMechanicalPerformance.setWaterReducerId(waterReducerId);//20
            sysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);//21
            sysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22
            sysMechanicalPerformance.setSlump(slump);

            batchInsertList.add(sysMechanicalPerformance);//


            //插入力学性能
            // 获取所有已存在的力学性能数据
//            LambdaQueryWrapper<SysMechanicalPerformance> wrapperSysMechanicalPerformance = new LambdaQueryWrapper<>();
//            List<SysMechanicalPerformance> listwrapperSysMechanicalPerformance = sysMechanicalPerformanceService.list(wrapperSysMechanicalPerformance);
//            Map<String, SysMechanicalPerformance> wrapperSysMechanicalPerformanceMap = new HashMap<>();

            LambdaQueryWrapper<SysSlump> wrapperSysMechanicalPerformance = new LambdaQueryWrapper<>();
            List<SysSlump> listwrapperSysMechanicalPerformance = sysSlumpService.list(wrapperSysMechanicalPerformance);
            Map<String, SysSlump> wrapperSysMechanicalPerformanceMap = new HashMap<>();


            // 将数据库中的所有数据按唯一组合键存入 Map
            for (SysSlump sysCement : listwrapperSysMechanicalPerformance) {
                String keySysMechanicalPerformance =
                        sysCement.getCementId() + "-" +
                                sysCement.getStone510Id() + "-" +
                                sysCement.getStone525Id() + "-" +
                                sysCement.getStone2040Id() + "-" +
                                sysCement.getStone1020Id() + "-" +
                                sysCement.getStone1030Id() + "-" +
                                sysCement.getStone010Id() + "-" +
                                sysCement.getStone2031Id() + "-" +
                                sysCement.getSandRiverCoarse3137Id() + "-" +
                                sysCement.getSandRiver2330MedId() + "-" +
                                sysCement.getSandRiver1622FineId() + "-" +
                                sysCement.getSandMech2330MedId() + "-" +
                                sysCement.getSandMech3137CoarseId() + "-" +
                                sysCement.getSandMech1622FineId() + "-" +
                                sysCement.getSandMech0475Id() + "-" +
                                sysCement.getSandMech09Id() + "-" +
                                sysCement.getStonePowderId() + "-" +
                                sysCement.getMineralPowderId() + "-" +
                                sysCement.getFlyAshId() + "-" +
                                sysCement.getWaterReducerId() + "-" +
                                sysCement.getEfficiencyAgentId() + "-" +
                                sysCement.getExpansionAgentId() + "-" +

                                sysCement.getWater() + "-" +
                                sysCement.getCement() + "-" +
                                sysCement.getStone510() + "-" +
                                sysCement.getStone525() + "-" +
                                sysCement.getStone2040() + "-" +
                                sysCement.getStone1020() + "-" +
                                sysCement.getStone1030() + "-" +
                                sysCement.getStone010() + "-" +
                                sysCement.getStoneCoarse20315() + "-" +
                                sysCement.getSandRiverCoarse3137() + "-" +
                                sysCement.getSandRiver2330Med() + "-" +
                                sysCement.getSandRiver1622Fine() + "-" +
                                sysCement.getSandMech2330Med() + "-" +
                                sysCement.getSandMech3137Coarse() + "-" +
                                sysCement.getSandMech1622Fine() + "-" +
                                sysCement.getSandMech0475() + "-" +
                                sysCement.getSandMech09() + "-" +
                                sysCement.getStonePowder() + "-" +
                                sysCement.getMineralPowder() + "-" +
                                sysCement.getFlyAsh() + "-" +
                                sysCement.getWaterReducer() + "-" +
                                sysCement.getEfficiencyAgent() + "-" +
                                sysCement.getExpansionAgent() + "-" +
                                sysCement.getRegion() + "-" +
                                sysCement.getProductionDate() + "-" +
                                sysCement.getSlump();

                wrapperSysMechanicalPerformanceMap.put(keySysMechanicalPerformance, sysCement);  // 使用一个唯一的组合键作为 map 的 key
            }
            System.out.println("数据库中的key" + wrapperSysMechanicalPerformanceMap);  // 打印生成的 key
            // 构建新的唯一键
            String keySysMechanicalPerformance = cementId + "-" + stone510Id + "-" + stone525Id + "-" + stone2040Id + "-" + stone1020Id + "-"
                    + stone1030Id + "-" + stone010Id + "-" + stone20315Id + "-" + sand3137Id + "-" + sand2330Id + "-"
                    + sand1622Id + "-" + sand2330BId + "-" + sand3137BId + "-" + sand1622BId + "-" + sand0475Id + "-"
                    + sand09Id + "-" + otherAdmixturesId + "-" + mineralPowderId + "-" + flyashId + "-"
                    + waterReducerId + "-" + efficiencyAgentId + "-" + sysSwellingId + "-" + water + "-" + cement
                    + "-" + stone510 + "-" + stone525 + "-" + stone2040 + "-" + stone1020 + "-" + stone1030 + "-" + stone010 + "-" +
                    stone20315 + "-" + sand3137 + "-" + sand2330 + "-" + sand1622 + "-" + sand2330B + "-" + sand3137B + "-" + sand1622B + "-" + sand0475 + "-" +
                    sand09 + "-" + otherAdmixturesStonePowder + "-" + mineralPowder + "-" + flyash + "-" + waterReducer + "-" + efficiencyAgent + "-" + swellinAagent + "-" +
                    regiona + "-" + productionDate + "-" + slump;


            System.out.println("现在的key" + keySysMechanicalPerformance);
            // 检查是否已经存在相同的力学性能数据
            if (wrapperSysMechanicalPerformanceMap.containsKey(keySysMechanicalPerformance)) {
                // 数据已存在，跳过插入
                System.out.println("力学性能数据已存在，跳过啦哈哈哈哈哈");
            } else {
                // 数据不存在，插入新数据
                // SysMechanicalPerformance newSysMechanicalPerformance = new SysMechanicalPerformance();

                SysSlump newSysMechanicalPerformance = new SysSlump();
                newSysMechanicalPerformance.setCementId(cementId);
                newSysMechanicalPerformance.setStone510Id(stone510Id);
                newSysMechanicalPerformance.setStone525Id(stone525Id);
                newSysMechanicalPerformance.setStone2040Id(stone2040Id);
                newSysMechanicalPerformance.setStone1020Id(stone1020Id);
                newSysMechanicalPerformance.setStone1030Id(stone1030Id);
                newSysMechanicalPerformance.setStone010Id(stone010Id);
                newSysMechanicalPerformance.setStone2031Id(stone20315Id);
                newSysMechanicalPerformance.setSandRiverCoarse3137Id(sand3137Id);
                newSysMechanicalPerformance.setSandRiver2330MedId(sand2330Id);
                newSysMechanicalPerformance.setSandRiver1622FineId(sand1622Id);
                newSysMechanicalPerformance.setSandMech2330MedId(sand2330BId);
                newSysMechanicalPerformance.setSandMech3137CoarseId(sand3137BId);
                newSysMechanicalPerformance.setSandMech1622FineId(sand1622BId);
                newSysMechanicalPerformance.setSandMech0475Id(sand0475Id);
                newSysMechanicalPerformance.setSandMech09Id(sand09Id);
                newSysMechanicalPerformance.setStonePowderId(otherAdmixturesId);
                newSysMechanicalPerformance.setMineralPowderId(mineralPowderId);
                newSysMechanicalPerformance.setFlyAshId(flyashId);
                newSysMechanicalPerformance.setWaterReducerId(waterReducerId);
                newSysMechanicalPerformance.setEfficiencyAgentId(efficiencyAgentId);
                newSysMechanicalPerformance.setExpansionAgentId(sysSwellingId);//22

                newSysMechanicalPerformance.setWater(water);
                newSysMechanicalPerformance.setCement(cement);
                newSysMechanicalPerformance.setStone510(stone510);
                newSysMechanicalPerformance.setStone525(stone525);
                newSysMechanicalPerformance.setStone2040(stone2040);
                newSysMechanicalPerformance.setStone1020(stone1020);
                newSysMechanicalPerformance.setStone1030(stone1030);
                newSysMechanicalPerformance.setStone010(stone010);
                newSysMechanicalPerformance.setStoneCoarse20315(stone20315);
                newSysMechanicalPerformance.setSandRiverCoarse3137(sand3137);
                newSysMechanicalPerformance.setSandRiver2330Med(sand2330);
                newSysMechanicalPerformance.setSandRiver1622Fine(sand1622);
                newSysMechanicalPerformance.setSandMech2330Med(sand2330B);
                newSysMechanicalPerformance.setSandMech3137Coarse(sand3137B);

                newSysMechanicalPerformance.setSandMech1622Fine(sand1622B);
                newSysMechanicalPerformance.setSandMech0475(sand0475);
                newSysMechanicalPerformance.setSandMech09(sand09);

                newSysMechanicalPerformance.setStonePowder(otherAdmixturesStonePowder);

                newSysMechanicalPerformance.setMineralPowder(mineralPowder);
                newSysMechanicalPerformance.setFlyAsh(flyash);
                newSysMechanicalPerformance.setWaterReducer(waterReducer);

                newSysMechanicalPerformance.setEfficiencyAgent(efficiencyAgent);
                newSysMechanicalPerformance.setExpansionAgent(swellinAagent);

                /* 掺量结束*/
                newSysMechanicalPerformance.setRegion(regiona);
                newSysMechanicalPerformance.setProductionDate(productionDate);
                newSysMechanicalPerformance.setSlump(slump);
//                newSysMechanicalPerformance.setStrengthGrade(strengthGrade);
//
//
//                newSysMechanicalPerformance.setCompressive3d(compressive3d);
//                newSysMechanicalPerformance.setCompressive7d(compressive7d);
//                newSysMechanicalPerformance.setCompressive28d(compressive28d);
                newSysMechanicalPerformance.setCreateTime(LocalDateTime.now());
                // 插入新数据
                try {
                    sysSlumpService.save(newSysMechanicalPerformance);
                } catch (Exception e) {
                    throw new RuntimeException(e);
                }
                System.out.println("力学性能数据不存在，已插入哈哈哈哈哈");
            }


        }


        return AjaxResult.success();
    }


    @PostMapping("updateExcelAudit")
    public AjaxResult updateExcelAudit(@RequestBody UpdateExcelAuditDTO updateExcelAuditDTO) {
        
        Integer id = updateExcelAuditDTO.getId();
        LambdaUpdateWrapper<SysExcelAudit> updateWrapperV2 = new LambdaUpdateWrapper<>();
        updateWrapperV2.eq(SysExcelAudit::getId, id);
        updateWrapperV2.eq(SysExcelAudit::getIsWarehouse,1);

        SysExcelAudit one = sysExcelAuditService.getOne(updateWrapperV2,false);

        if (one != null) {
            return AjaxResult.error(409, "已入库，请勿重新操作");
        }

        
        Integer isWarehouse = updateExcelAuditDTO.getIsWarehouse();

        LambdaUpdateWrapper<SysExcelAudit> updateWrapper = new LambdaUpdateWrapper<>();
        updateWrapper.eq(SysExcelAudit::getId, id)
                .set(SysExcelAudit::getIsWarehouse, isWarehouse);

        boolean updated = false;
        try {
            updated = sysExcelAuditService.update(updateWrapper);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }

        return updated ? AjaxResult.success("更新成功") : AjaxResult.error("更新失败");
    }


}
